[Need help]How to add several rb_files to a sub_menu
-
My target is adding every plugins that I wrote to a certain sub_menu.
I try to add codes as below to every rb files.But it sames that only the first loaded rb file can add item to the menu correctly.
if !$my_menu $my_menu=UI.menu("Plugins").add_submenu("My_Tools") end $my_menu.add_item("some_string") { some_code}
I test following code in a rb file.It works well.
a_menu=UI.menu("plugins") a_menu.add_item("print") { p "1"*10 }
But when I run each line of following in Ruby Console.It does't work at all!
a_menu=UI.menu("plugins") a_menu.add_item("print") { p "1"*10 }
It is a puzzle to me.
-
I think it can only be done when SketchUp loads. Once SU is loaded, you can no longer add items to a submenu. That has been my experience. And I have problems somtimes where my plugins will still split themselves up into 2 "Chris Fullmer Tools" submenus. So putting all .rbs into the same submenu is do-able on loading, but still a little buggy I think. I don't know if SU was designed to wokr like that.
Chris
-
Thank you!
I tested it.As what you say ,when sketchup initialize , my rb files can add themself to the same submenu.
Advertisement