Adding items to an existing sub menu
-
In an attempt to get better organized, I was attempting to create a submenu and add items to it using this code
# ------------------ MENU SETUP ---------------------- # unless $sdm_tools_menu $sdm_tools_menu = UI.menu("Plugins").add_submenu("SDM Tools") end unless file_loaded?(__FILE__) $sdm_tools_menu.add_item("Plugin Name") { SDM;;Module_Name.main } file_loaded(__FILE__) end # ------------------------------------------------------ #
I created a two dummy plugins and loaded them using the Ruby Console with load 'c:/.../dummy1.rb'
I check the plugins menu and the sub menu has been created and the item added.
I repeat the load process for dummy2. I know it loaded because I can execute it from the Ruby Console but it was not added to the sub menu.
To complicate the situation, if I copy the dummy plugins to the Sketchup Plugins folder and start Sketchup, they are both in the sub menu. So what's the difference?
-
@sdmitch said:
so what's the difference?
Time. The references to the sub-menus are only available for a short time.
Dan can probably tell us why, but that's just how sub-menus currently work. No way around it, unfortunatly.
-
So even though the global variable retains lts value, the entity it references doesn't exist?
-
@sdmitch said:
So even though the global variable retains lts value, the entity it references doesn't exist?
I don't know the internals. But as yoou noticed, even when the global variable appears to reference a valid menu object, new items are not added after some short amount of time.
Advertisement