Asking question and help
-
I have 10 components or dynamic components that I load into a model more than once per model. I wish to add a toolbar, with an icon representing the component, such that I select the icon and the component is loaded into the model. Below is code that I have copied from another script. TIG's I believe, and thank you for not encrypting you plugins.
I am wondering can the below code be change such that after selecting the icon, a component that I assign to this code is loaded. I wish to have a toolbar that I can add icon for the most used components. At the most 10 components.
I have been looking at different plugins to see if I can find any code that would help, however, I haven't found any code that I can decipher that would help.
I know that I can add the component to a template file. However, for some reason after modeling for some time, the component browser does not work, so this is my work around.
Thank you in advance.
if not file_loaded?(File.basename(FILE))
toolbar = UI::Toolbar.new "Ken Tools"
cmd = UI::Command.new("Plugin Description") { insertselectedcomponent }
cmd.small_icon = "A_KenIconUse/Image to use sm.png"
cmd.large_icon = "A_KenIconUse/Image to use lg.png"
cmd.tooltip = "Tool tip text"
cmd.status_bar_text = "Status bar Help text"
toolbar = toolbar.add_item cmd
file_loaded(File.basename(FILE))
end -
cmd0=UI::Command.new("Plugin Description") { insertselectedcomponent(0) }
cmd1=UI::Command.new("Plugin Description") { insertselectedcomponent(1) }
cmd2=UI::Command.new("Plugin Description") { insertselectedcomponent(2) }
etc
with corresponding icons for each command.Then in the method 'def insertselectedcomponent(num=0)' itself
You look for 'num' with a case structure
case num
when 0
comp="ABC"
when 1
compo="BCD"
etc
ebd
Now you have a comp[nent] set by name.
So you can load it etc using that... -
TIG
Thank you for the reply.
For some reason yesterday, I couldn't get back on this site.
Ken
Advertisement