How to Change the Extension's UI from the Ruby Script?
-
Dear Sketchucationers,
Looking for a quick intro/tutorial into how to manipulate the UI aspect of .rb scripts. For example, how can I change where an extension appears on the menu bar? or how can I change the items that appear in the context-click menu? Some Ruby tips appreciated too!
-
Look through my RB scripts and see how this is done in detail...
for a simple menu item
SUBMENU=UI.menu("Plugins").add_submenu("Haujiet") #Or other menu by name e.g. 'Tools' SUBMENU.add_item("Add..."){Sketchup.active_model.select_tool(Haujiet_Tool.new())} SUBMENU.add_item("Settings..."){Haujiet_Module;;settings()}
for a command
CMD1=UI;;Command.new("Tool_name"){Haujiet_Module;;some_module_action()} CMD1.tooltip="How_to_use_tool..." CMD1.status_bar_text="How_to_use_tool..." CMD1.small_icon=File.join(FOLDER_path, 'icon.png') CMD1.large_icon=File.join(FOLDER_path, 'icon.png')
and for Toolbar
TOOLBAR=UI;;Toolbar.new("Haujiet...") TOOLBAR.add_item(CMD1) TOOLBAR.restore if TOOLBAR.get_last_state.abs == 1 #TB_VISIBLE/NEVER
for a context menu
UI.add_context_menu_handler{|menu| sub = menu.add_submenu("Haujiet...") sub.add_item(CMD1) # perhaps with tests to see if it should show - e.g. the selection is a group? }
See here...
http://ruby.sketchup.com/UI/Command.html
http://ruby.sketchup.com/UI/Toolbar.html
Advertisement