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

    Menue definition - small problem

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 214 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.
    • artmusicstudioA Offline
      artmusicstudio
      last edited by

      hi,
      with my code i have the following problem:
      every time i restart the ruby in the ruby console per

      load '01.rb'

      the menue entry in the plugins-menue is duplicated (so after 5 calls 5 times the menue, the first one at the top, all the others then call by call at the botton of the plugins menue...))

      where is the problem?

      
      Sketchup.send_action "showRubyPanel;"
      
      submenu = UI.menu("Plugins").add_submenu("01-zf-ruby")
      submenu.add_item("1 ruby"){
      meth_1
      meth_2
      }
      
      submenu.add_separator
      submenu.add_item("2 save last model"){
      meth_3
      meth_4
      }
      
      submenu.add_separator
      submenu.add_item("3 load saved model"){
      meth_5
      meth_6
      }
      
      submenu.add_separator
      submenu.add_separator
      submenu.add_item("4 support"){
      UI.messagebox "support" # w.i.p.
      }
      
      

      thanx for checking and helping.
      stan

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        @artmusicstudio said:

        ... every time i restart the ruby ... the menue entry in the plugins-menue is duplicated ... where is the problem?

        Use a block of code that runs only ONCE per session:

        
          Sketchup.send_action "showRubyPanel;"
          
          ### load SketchUp global methods so we can
          #    use file_loaded?() and file_loaded()
          #
          require("sketchup.rb")
        
          THISFILE = File.basename(__FILE__)
          
          #{# RUN ONCE PER SESSION
          #
          unless file_loaded?(THISFILE)
        
            submenu = UI.menu("Plugins").add_submenu("01-zf-ruby")
            submenu.add_item("1 ruby"){
              meth_1
              meth_2
            }
        
            submenu.add_separator
            submenu.add_item("2 save last model"){
              meth_3
              meth_4
            }
        
            submenu.add_separator
            submenu.add_item("3 load saved model"){
              meth_5
              meth_6
            }
        
            submenu.add_separator
            submenu.add_separator
            submenu.add_item("4 support"){
              UI.messagebox "support" # w.i.p.
            }
            
            # mark THISFILE as loaded;
            file_loaded(THISFILE)
            
          end #}# RUN ONCE PER SESSION
        
        

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • artmusicstudioA Offline
          artmusicstudio
          last edited by

          hi dan,
          super, thanx, i understood and it works now,
          besides a small message in the console:


          load '01.rb'
          C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:66: warning: already initialized constant THISFILE
          true


          i start the ruby directly, not in a module (when i put it in the module, it does not work, probably because of all the entities definitions etc. / still workin' on it)

          regards stan

          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