• Black Twitter Icon
  • Black Facebook Icon
  • Instagram
  • Black YouTube Icon

Secrets revealed on how to register a SketchUp extension with toolbar button and menu item.


We are learning how to register our script as an extension so it can automatically load every time we start SketchUp. We also want to create a toolbar button and a menu item for activating our extension.


I am going to provide you with a template for you to download and use as a base for your extension.



Download Extension Template


The download will provide you with a .zip archive for you to extract and edit.


The most important step is step #3 because there is where you write your main script. Start by copying the code from my first or second tutorial and pasting it on line 8 in 'toolname.rb' file. Then after the files are in the plugin folder you will have a full working extensions with toolbar button and menu item the next time you launch SketchUp.


Then start experimenting by writing your own scripts and if you get stuck, go to a SketchUp forum and ask around. It's not important for you to understand what each line of code does at this stage but they'll become more clear to you.


If you want to accelerate your understanding of the code I recommend the following books...






Click the link and get a copy of this book, it will give you the knowledge to start coding with Ruby which is the language that SketchUp uses to create Extensions/Plugins.


Programming Ruby 1.9 & 2.0









This is the only book I know that is specific to SketchUp programming and I can't recommend it enough!


Automatic SketchUp







Below is the code of the template provided...


STEP 1 : Open and edit 'PluginName.rb'




SketchUp API:

SketchupExtension , #description , #version , #copyright , #creator

SketchUp , #register_extension


STEP 2 : Open and edit 'loader.rb'




SketchUp, #require , #active_model

UI, #menu , #toolbar

UI::Toolbar , #add_item , #show

UI::Comand , #small_icon , #large_icon , #tooltip , #status_bar_text , #menu_text

Model , #select_tool


STEP 3 : Open and edit 'toolname.rb'



Put your code here!

Hope this is useful to you but before you go please visit the extension store and see what we got to offer. Have a nice day and expect another blog post next week!

167 views
0