Menue definition - small problem
-
hi,
with my code i have the following problem:
every time i restart the ruby in the ruby console perload '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 -
@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
-
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
Advertisement