sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Adding items to an existing sub menu

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 198 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sdmitchS Offline
      sdmitch
      last edited by

      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?

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        @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.

        Hi

        1 Reply Last reply Reply Quote 0
        • sdmitchS Offline
          sdmitch
          last edited by

          So even though the global variable retains lts value, the entity it references doesn't exist?

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            @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.

            Hi

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement