Learning Ruby for SketchUp

Hi all,

I decided to write here as I thought it would be the best place to ask and gather information from other generous people.

Recently, I had been thinking I should really pick up how to code or write scripts in Ruby to enhance my modeling process in SketchUp. I realize that I can achieve so much with short and simple script/coding in SketchUp. I do not intend to learn to the extent where I produce full SketchUp extensions (perhaps I might be able to), but just enough to aid my modeling process for now.

I am very comfortable in modeling and can utilize multiple extensions that you amazing developers have generously contributed to the community. But sometimes, I wish it was done slightly different, or just do simple operations to fill the gaps between other great extensions that are already available. Sometimes I come across tedious tasks where I have to move and scale hundreds of objects, and I am thinking several lines of scripts on the console with aid me greatly.

I am tech savvy. I build my own machines, can fix software problems as long as they let me by doing some registry changes, type couple of lines in CMD that I can find by Googling. But I am limited as I do not have any experience in coding or programming. I don’t know how I have left that un-learned so long. I can sometimes kind of figure out the logics when looking at the written script, and change some values to suit what I want, but that is about it. I am sure many people can do such things without knowing the language at all.

So, the question:
How difficult would it be to reach the level of writing scripts for simple operations such as move, scale, change axes… for multiple objects?
Where and how will be a great way to achieve this?

I don’t wish to start digging out “Basics in programming” tutorials as things that I learn there are Java, C++ which I might not need at all for this purpose. Or heck, do I need to learn all of that?

1 Like

There are also “Basics in programming” tutorials specific to Ruby. But for many people, learning programming theoretically (from begin to end of a book) is not the best way. Often people bring already some experiences and want to pick up what enhances their knowledge. And also the strongest accelerator is having your own (little) “project”. That said, we have had a lot of beginners trying to start with a “big thing” without having an understanding of basics (like variable scope).

Refer to these resources:

If you have some understanding of programming and want to focus on SketchUp, jump to the SketchUp-specific section.
If you want don’t want to spend much time learning the language, get a feeling for the language with Try Ruby.

SketchUp’s Ruby API is modelled after the scene graph that are used to as a modeller (entities, components, materials). The principle of exploratorive learning is that you get a reference to something (e.g. a selected entity), find out its class, then go in the SketchUp Ruby documentation to the page for this class. It lists all methods that are available. After trying out a method, you can proceed with the returned value the same way.

groups = Sketchup.active_model.entities.grep(Sketchup::Group)
groups.each{ |group| group.move!([10,-50,100]) }

Not difficult!


Oh dear. Thank you so much for the detailed answer!

This is enough of content for me to chew through.

Which coding program do you think is a good one to start with?

Input directly into Ruby Console for a few days at least…

then look for an external code editor…


1 Like

I’ve used Notepad++ with success on Windows, before I switched to an iMac and TextWrangler.

Or you can set up an Integrated Development Environment (IDE) - search this forum for NetBeans, for example - this thread in particular.


We started creating some examples/tutorials for creating extensions. So far we got the very basic; GitHub - SketchUp/sketchup-ruby-api-tutorials: SketchUp Ruby API Tutorials and Examples


The built-in console can quickly become frustrating. There have been several attempts to built a solution that brigdes the gap between the built-in console and a full-fletched IDE. This is probably most appropriate for starters or for quick exploration of ideas and code:


Aerilius, your

Go to the releases page (↑) and download the latest .rbz file.

link is broken, but the normal clone/download work fine…


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