Greetings superior minds.
On occasions I have to create or modify the attributes on a couple of object instances.
This is really time consuming especially when you need to add a lot of attributes.
I tried to use the object toolkit but it seems that it requires you to have a full version of Visual Studio and not just Visual Studio Express/Community.
Does anyone have any pointers or something I can look into to make this process a little less effort?
Up until now I have written a small Ruby script to make this process a little easier but I suspect there might be something simpler.
tag_name = "My_Tag_Name"
template_name = "$b_UserDefined"
attributes = [[5, "float", "0.0", "UDA_DAM", "Level for Dam"],
[2, "float", "1.0", "UDA_DAM_ML", "The size of the dam"],
[8, "bool", "FALSE", "UDA_FLAG", "Flag bit for Dam"],
[1, "string", "A String", "UDA_STRING", "A Random String"]]
# [quantity, type, default value, name, description]
portion_0 = p %{; Go to: "Galaxy" > "Import" > "Galaxy Load"
; Created by
:TEMPLATE=#{template_name}
:Tagname,UDAs} # The template
portion_1 = p %{\n#{tag_name},"<UDAInfo>} # The UDA Info
portion_2 = "" # The Values
# UDAs
attributes.each_with_index do |attrib, i|
repeat_nr = attrib[0]
(1..repeat_nr).each do |j|
if attrib[1] == "bool"
portion_0 += p %{,#{attrib[3]}#{j.to_s.rjust(2, '0')},#{attrib[3]}#{j.to_s.rjust(2, '0')}.Description}
portion_1 += p %{<Attribute Name=""#{attrib[3]}#{j.to_s.rjust(2, '0')}" DataType=""MxBoolean"" Category=""MxCategoryWriteable_USC_Lockable"" Security=""MxSecurityOperate"" IsArray=""false"" HasBuffer=""false"" ArrayElementCount=""0"" InheritedFromTagName=""""/>}
portion_2 += p %{,#{attrib[2]},#{attrib[4]} #{j.to_s.rjust(2, '0')}}
elsif attrib[1] == "string"
portion_0 += p %{,#{attrib[3]}#{j.to_s.rjust(2, '0')},#{attrib[3]}#{j.to_s.rjust(2, '0')}.Description}
portion_1 += p %{<Attribute Name=""#{attrib[3]}#{j.to_s.rjust(2, '0')}"" DataType=""MxString"" Category=""MxCategoryWriteable_USC_Lockable"" Security=""MxSecurityOperate"" IsArray=""false"" HasBuffer=""false"" ArrayElementCount=""0"" InheritedFromTagName=""""/>}
portion_2 += p %{,#{attrib[2]},#{attrib[4]} #{j.to_s.rjust(2, '0')}}
elsif attrib[1] == "float"
portion_0 += p %{,#{attrib[3]}#{j.to_s.rjust(2, '0')},#{attrib[3]}#{j.to_s.rjust(2, '0')}.Description}
portion_1 += p %{<Attribute Name=""#{attrib[3]}#{j.to_s.rjust(2, '0')}"" DataType=""MxFloat"" Category=""MxCategoryWriteable_USC_Lockable"" Security=""MxSecurityOperate"" IsArray=""false"" HasBuffer=""false"" ArrayElementCount=""0"" InheritedFromTagName=""""/>}
portion_2 += p %{,#{attrib[2]},#{attrib[4]} #{j.to_s.rjust(2, '0')}}
end
end
end
portion_1 += "</UDAInfo>\""
script = portion_0 + portion_1 + portion_2
file_name = p %{Import this file #{Time.now.strftime("%Y-%m-%d %Hh%M_%S")}.csv}
File.open(file_name, 'w') { |f| f.write(script) }