Please correct this snippet of code

plugins_menu = UI.menu(‘Plugins’)
submenu = plugins_menu.add_submenu(‘myTest’)

submenu.add_item(‘aa’){load ‘C:/Users/imode/AppData/Roaming/SketchUp/SketchUp 2018/SketchUp/Plugins/ams_FixIt.rb’ }
#load “full path to/scripta.rb”
#submenu.add_item(‘a’){ams_FixIt.rb }
submenu.add_item(‘b’){ scriptb.rb }

I’m trying to get by clicking aa to run fixit

your codes ‘logic’ makes little sense…

SU will have already loaded ams_FixIt.rb before your menu item is even made…

submenu.add_item(‘b’){ scriptb.rb } will just cause an error…

what is your actual problem?

edit:

where did the ruby come from, I suspect it is very old and not working in v18?

FixIt 101 from SketchUcation works in v18…

I have moved move the post to the Ruby forum, and add the missing information to your question and your forum profile…

if you want to add a submenu under your own ‘title’ you need to structure your own plugin…

john

Thanks for reply. I found this code on the internet. Just started using ruby. I would like to build a toolbar with all my 3d printing plugins. Perhaps you could point me in the right direction to find samples.

How would I move this query to ruby forum

You would do well to study Ruby first so that you know what the syntax means. Then you would avoid issues such as

submenu.add_item('b){scriptb.rb}

which can’t possibly work because scriptb.rb is not a Ruby object and there is a missing quote on 'b. This is a syntax error!

Then I’d study sample extensions from sketchUcation’s plugin store (I recommend that because fewer of the extensions there are encrypted) and look up the specific calls in the SketchUp Ruby API documentation to understand what they are doing.

Your code adds to the extensions menu not to a toolbar. For toolbars

unless file_loaded?(__FILE__)
	tb = UI::Toolbar.new("Toolbar Name")
	#
	cmd = UI::Command.new("Method Name") { Method to Execute }
	cmd.tooltip = "Plugin Name"
	# cmd.status_bar_text = "What the plugin does"
	# cmd.large_icon = Sketchup.find_support_file "Large Icon.png","Plugins/Icons/"
	# cmd.small_icon = Sketchup.find_support_file "Small Icon.png","Plugins/Icons/"
	tb.add_item(cmd)
	#
	#Repeat for other cmd's
	#
	tb.show unless tb.get_last_state == 0
	#
	file_loaded(__FILE__)
end

I already did…

look at example ruby tutorials

john

Thanks

Thanks. Found this

toolbar = UI::Toolbar.new “Action 3D Toolbar”
cmd = UI::Command.new(“Explode All”) {
Sketchup.send_action(21101)
}
cmd.small_icon = “3dtoolbar.png”
cmd.large_icon = “3dtoolbar.png”
cmd.tooltip = “Action 3D Toolbar”
cmd.status_bar_text = “Testing the toolbars class”
cmd.menu_text = “Test”
toolbar = toolbar.add_item cmd
toolbar.show

Thank try it tomorrow.

@Hyman On the forum, please use color lexed code blocks with proper 2 space indentation.

1 Like

Thanks will look into that

#This is my entry

unless file_loaded?(FILE)
tb = UI::Toolbar.new(“Toolbar Name”)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.