How do I create a component from an instance I have drawn?

Well first of all, the API is an extension to Ruby language. It really helps to learn Ruby first.
There is a pinned topic here in this category I made just for people like yourself …

There are quite a few free downloadable books for you to read in your spare time (on the bus, on the “pot” etc.)


Secondly, the SketchUp API dictionary is a technical reference and not a learning text. It’s code examples are notorious for being frivolous or erroneous.

There is also much left unsaid in the API documentation (ie, tips and tricks and pitfalls, etc.) So when things act weird, come here and enter this category, and then use the :mag: menu (upper right) to search only this category. Chances are someone else has already run into the same “challenge”.

I strongly suggest first reading the primers on Ruby and then starting out with simple snippets in the console (or one of the console editor extensions) to get the feel of coding geometry.

Then move on to tasks a bit more complex, little by little. Otherwise you will become overwhelmed.

When you are finally ready to start a SketchUp extension, make sure you read and understand the organization of an extension’s files, and the SketchupExtension class …

The biggest thing you need to understand about embedded programming for an application is that it is event driven programming.

The code is sitting in memory waiting for the user to cause an event that fires off parts of your code.
It might be a simple thing like a new model was loaded, or the user clicked a toolbar button or made a menu choice.

Your code’s methods react to the events.


There are quite a few others that have already done all of these things in various modeling extensions, … so it is possible.

Well more power to ya’ … being young it’s often easier to learn new things. I encourage you to learn correctly instead of skipping ahead and losing your way. What I mean is build a solid general programming and Ruby syntax foundation instead of hacking away at a complex extension.

One of the best things to learn is coding style. There are some guides out there.
But basically Ruby style is readability. You do not help the interpreter by leaving out spaces.
(Spaces actually help the interpreter divide the code into parsing tokens.)

A blank line takes up only 2 invisible characters.

Likely others at their EW store page.

Also there are example repository on GitHub …