Learning to make a plugin/extension


I would like you to recommend me which documents are the best to read about how to make a plugin? And can you also recommend me any YouTuber who made tutorials on how to make a plugin for SketchUp?

I have tried youtube and I watched the tutorial on how to make a plugin for a Sketchup 2014, but it seems to be outdated because I made a simple plugin and I am having trouble with a line that is not working properly as it should be. I thought it must be because the year is 2014… but I do not have any issue with other lines at the beginning. So the line I am having issue is where I named the operation “example”, then the next line is “def example”

that should give you an idea what are the issue. I’m currently using Sketchup Make 2017

I would appreciate your advice and helping with my education.

The SketchUp Ruby API docs are essential:

If you don’t already know Ruby you’ll need a book on that too. Here’s a free one:

A plug-in written for SketchUp 2014 should still work in the latest version. Post the code you had problems with here and someone will help.

1 Like

I have created two extensions examples that perhaps are of help.

I learned quite a lot myself from reading other people’s code.

1 Like

You might want to have a look at some of the examples we have on our GitHub account - they are more up to date: SketchUp · GitHub

Specifically the Examples and Tutorial repository: GitHub - SketchUp/sketchup-ruby-api-tutorials: SketchUp Ruby API Tutorials and Examples
It contain example of bare minimum for a Hello World extension. as well as a minimal example for a simple custom tool.

1 Like

And learning Ruby is essential:

1 Like

Everyone, thank you for providing a guide to learning the Ruby. I’ll be sure to use all of them for my education but Is the book below useful?

“The 4th Pragmatic Programmer, Programming Ruby 1.9&2.0” by Dave Thomas with Chad Fowler and Andy Hunt

And is there a website where I can find out more information about the error message that is shown in Sketchup’s Ruby console?

  • Exception Handling primer

  • Exception class

    • See the description under the backtrace() method of how to read the error messages how they tell the file, the line number and the method where an exception occurred.
    • In the class description, has links to all it’s subclasses doc pages.
  • Kernel module is mixed into Object, so it is the ancestor of everything !
    It’s methods become global methods and need not be called with qualification:

It is one of the best and most complete Ruby references.
There are older online editions you can read to decide if you want to buy the most updated edition.

Thank you. I have been doing some studying. It’s going pretty well with trial and errors. But I am having trouble with finding the right code line that would allow me to specify a target in the SketchUp that I would want to remove or change. Is there a good document or somewhere. I have been looking for that information to get the correct information.

I appreciated your helping with this one.

There are two ways to get references to specific entities. You can either use selection or you could implement a tool that lets users click entities themselves. The former is by far the easiest.

If you don’t mind tell me which is the former that is easier?

What I am trying to find out the automatic way.

Referencing the selection is the easiest. If the user has selected an entity you can reference it as:


It looks like there is no automatic method at all. That’s too bad.

alright. Thank you for helping me out.

What do you mean by automatic method?

what I mean is that I don’t have to select the specific entity every time I started up a new project and have it removed. This is an automatic method. It’s a very simple method that I can learn from making my own plugin.

How is the target entity specified if not selected by the user?

the specific target is “Chris”, it’s a dynamic model/entity. I wanted to remove it every time I started a new project using the program. But the problem is I am not sure how to target that entity that it has an ID or other information that should be the exact same thing every time I started a new project. That’s the ideal for an automatic method, but my hobby is that I make an model of any vehicles.

the simple plugin is where I would remove that “Chris” and automatically put up a rectangle so I can place the blueprint on that rectangle. without having to do the selection in manually way. This is a good way for me to learn how to programming. where I would learn how to do the basic functions such as removing, adding, or others

You can just use a template with no scale figure if you don’t want to have a scale figure.

If you really want to achieve this through scripting you could use the PID (persistent ID) of that component instance to target it. To get the PID in the first place you can use Sketchup.active_model.selection.first.persistent_id. Then you should be able to use Model#find_entity_by_persistent_id to retrieve a reference to the same entity later.


okay. Can you give me a good example of how would you build lines of function with the information you’ve provided? Please keep this in mind, I am a beginner, so thank in advances.

I agree with @eneroth3. I am not clear why you want to do this via code when the easier way is if you don’t want something in the model, don’t put it there in the first place. By that I mean open a new blank file, erase Chris, and then save as template default. From then on you won’t have him there and won’t need to remove him.