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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement