sketchup, sketchup tutorials, sketchup tips, sketchup plugins, armedia, vray
Linkedin Myspace Facebook Twitter Google Plus
Sketchup-ur-space Magazine - June 14

Author : Debarati Nath

Ruby Script and SketchUp The Super Combi Pack

We know that Google SketchUp is cult software which created an awesome impact on 3D industry. You can create a box or a table or a building or a bridge with the help of this magic tool. But we always like to enhance the functionalities of this software. And for this reason we like to add the plug ins with SketchUp to get the finest result in 3D modeling. Various types of plug ins like rendering, performance analyzer and many others are available which are helping SketchUp to serve well. With the help of Ruby, the programming language you can use to write the scripts of the plugins of SketchUp. You can easily improve the way you work with SketchUp by installing the Ruby Scripts which can add tools, simplify multi-step operation. 

Ruby Script is a dynamic, general purpose object-oriented programming language with a focus on simplicity and productivity. Ruby was first designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan. The creator, Yukihiro “matz” Matsumoto, combined parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, and Lisp) to form a new language that balanced functional programming with imperative programming. Building on this, he adds “Ruby is simple in appearance, but is very complex inside, just like our human body”.
You don’t need to be an expert in programming language to write a program in Ruby script. You can take help from the pre made Ruby Scripts and can extend the capability of Google SketchUp. A SketchUp plugin adds extra functionality to the overall application, such as new menu items, new tools in the toolbar, new dialog boxes, and many other possibilities with existing built-in properties. A plugin is just a SketchUp script in the right directory.

sketchupruby

Ruby is a language of careful balance with following advantages:

  1. Object oriented approach: In Ruby, everything is an object. Every bit of information and code can be given their own properties and actions. Object-oriented programming calls properties by the name instance variables and actions are known as methods. Ruby’s pure object-oriented approach is most commonly demonstrated by a bit of code which applies an action to a number.

  2. Flexibility: It allows its users to freely alter its parts. Essential parts of Ruby can be removed or redefined as well. Existing parts can be modified. Ruby tries not to restrict the coder. You can redefine the operators as well.

  3. "Mixin" functionality by module: Ruby allows single inheritance only, on purpose. But Ruby knows the concept of modules (called Categories in Objective-C). Modules are collections of methods. Classes can mixin a module and receive all its methods for free. Generally, this is much clearer way than multiple inheritances.

  4. Ruby needs no variable declarations. It uses simple naming conventions to denote the scope of variables. For e.g. var could be a local variable, @var is an instance variable, $var is a global variable.

  5. Block: Ruby’s blocks are also seen as a source of great flexibility. A programmer can attach a closure to any method, describing how that method should act. The closure is called a block and has become one of the most popular features for newcomers to Ruby from other imperative languages like PHP or Visual Basic.

  6. Ruby is highly portable: It is developed mostly on GNU/Linux, but works on approx all versions of UNIX, Mac OS X, Windows 95/98/Me/NT/2000/XP, DOS, BeOS, OS/2, etc.

  7. Less Hardware requirements: The hardware requirements for installing Ruby are the same as the hardware requirements for the underlying operating system on which you have chosen to run Ruby. Therefore, you do not require any special hardware for installing Ruby.

  8. Ruby has exception handling features, like Java or Python, to make it easy to handle errors.

  9. Ruby can load extension libraries dynamically if an OS allows.

  10. Ruby features OS independent threading. Thus, for all platforms on which Ruby runs, you also have multithreading, regardless of if the OS supports it or not, even on MS-DOS!

  11. Ruby features a true mark-and-sweep garbage collector for all Ruby objects. No need to maintain reference counts in extension libraries.

Writing C extensions in Ruby is easier than in Perl or Python, with a very elegant API for calling Ruby from C. This includes calls for embedding Ruby in software, for use as a scripting language. A SWIG interface is also available.

If you want to write plugins for Google SketchUp then it will be best for you to use Sketchup’s Ruby API. You can write your own tool with the help of this API and in this way you can query and influence the SketchUp models. This process is working both of the free and pro versions of Google SketchUp. And the best part of this SketchUp Ruby API is that it is free.

sketchupruby

But how to start with it? Here is the step by step instruction on how to install and start with Ruby Scripts.

1. Download the Ruby onto your computer.
2. If the downloaded file is zipped, unzip it. You can usually do this by double-clicking on it. Unzipped Ruby Script files have the following file extension: .rb
3. Close SketchUp if it's running.
4. Copy the Ruby Script file into the right location for your operating system:
      Windows: C:/Program Files/Google/Google SketchUp 8/Plugins
      Mac OS X: 'Hard Drive'/Library/Application Support/Google SketchUp 8/SketchUp/Plugins

There are plugins like Ruby Web Console, available to download free of cost which are used to simplify the whole operation. You can just take help of pre-programmed plugins and guide book and can write customized plugins for Google SketchUp. 

The location of the Ruby script’s controls may be varied due to the scripts. Some can access it through the menu system and others by right clicking on the elements of the model. Few scripts of the Ruby  have own dialogue boxes and others’ dialogue boxes don’t appear in the interface of the SketchUp users which are the only reference scripts which is providing the extra functionality for SketchUp.

sketchupruby

There are many renowned Google SketchUp plugin programmers in Ruby Script like Thomas Thomassen, Jim Folts, Alexander Schreyer, Didier Bur who are writing plugins to enhance the functionality of Google SketchUp. You can find scripts of plug ins in the website Ruby Library Depot.

What do you think about this article