Chapter 27. Scripting with Ruby

SketchUp was developed by a team of programmers using the latest programming techniques and tools. These tools keep the code secure and prevent hackers from altering the code. It preserves the code integrity and keeps it safe, but it also prevents the base code from being altered.

However, the programmers have also written the code in such a way that the internal structures of the program are open and can be accessed using a scripting language.

The scripting language that is supported by SketchUp is Ruby. Using Ruby scripts, you can add new functionality to the program.

Understanding Ruby Scripting

Scripting languages, such as Ruby, are founded on key programming concepts, but they are also generally easier to understand and write than a full-blown coding language like C++ or Java. Ruby scripts are interpreted, which means that they are written using normal text syntax. These text commands are read and interpreted by the code as the script is run.

Ruby scripts don't require any fancy development tool or compiler. The scripts are written using any standard text editor and are saved using the .rb extension.

Accessing the Ruby Help files

The textual syntax for interfacing with SketchUp comes from the established Application Programming Interface (API) developed by the SketchUp team. This API contains all the keywords that are needed to access the internal program feature. ...

Get Google® SketchUp® and SketchUp® Pro 7 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.