Hello. I have a problem that i can't solve atm and i could use some help.
I have a sketchup model that contains some component instances that represent sensors. I made a context menu entry that executes a command for a webdialog to be created. This webdialog will retrieve information for the sensor that is attached to it.
How can i create a separate webdialog instance that i can manipulate without interfering with another webdialog from the same command?
here is the code
require "sketchup.rb"
module XXX
model = Sketchup.active_model # point to the active model
selected = model.selection # get the selected entities
cmd_settings = UI;;Command.new("Settings") {
settings_wd = UI;;WebDialog.new( "Main Settings", false, '', 200, 200, 500, 500, true )
settings_html_path = Sketchup.find_support_file "settings.html", "Plugins/xxx_plugin/"
settings_wd.set_file( settings_html_path )
settings_wd.set_position(640,480)
settings_wd.set_size(500,300)
settings_wd.show
}
cmd_main = UI;;Command.new("Get Sensor Data") {
if selected[1]==nil and selected[0].class==Sketchup;;ComponentInstance and selected[0].name.include?'Sensor'
main_wd = UI;;WebDialog.new( "#{selected[0].name}'s Info", false, '', 200, 200, 500, 500, true )
main_html_path = Sketchup.find_support_file "main.html", "Plugins/xxx_plugin/"
main_wd.set_file( main_html_path )
main_wd.set_position(800,600)
main_wd.set_size(250,250)
main_wd.add_action_callback("get_info") { |js_cb, params|
main_wd.execute_script("show_selected('#{selected[0].name}', '#{selected[0].class}')")
}
main_wd.show
else
UI.messagebox('Selected entity is not a Sensor Component or you have selected more than one entities.')
end
}
unless file_loaded?(__FILE__)
# Access SketchUp's Edit menu
edit_menu = UI.menu "Plugins"
sub_menu = edit_menu.add_submenu("xxx Plugin")
item = sub_menu.add_item cmd_settings
# Access SketchUp's context menu
UI.add_context_menu_handler do |menu|
menu.add_separator
item = menu.add_item cmd_main
end
file_loaded(__FILE__)
end
end
thank you