Draw Ruby

There are two major variants of the Draw Ruby plugin. Each of them draws a stylized 3D Ruby logo; they differ, however, in their user interface. Draw Ruby 1 uses a semi-custom confirmation dialog (ie, UI.messagebox), while Draw Ruby 2 uses a fully-custom WebDialog (specified by the plugin using HTML, JavaScript, and CSS).

Draw Ruby 1

Start up a copy of SketchUp, then select the Draw Ruby 1 plugin (eg, Plugins > SketchApps > CFCL > Toys > Draw Ruby 1). A confirmation dialog should appear. Click "Yes" to cause the Ruby logo to be drawn:

This should create a 3D, opaque version of the Ruby logo. If it doesn't, please contact me and I'll try to help.

After examining and admiring the ruby, select all (cmd-A on a Mac; ctrl-A on Windows) and hit delete. The ruby should disappear, leaving you ready to try Draw Ruby 2.

Draw Ruby 2

There are three versions of this plugin (ERb, File, and HTML), with differing behavior and implementations. For now, we'll concentrate on the ERb version.

Draw Ruby 2 (ERb) uses Embedded Ruby (etc) to generate temporary files (eg, CSS, HTML, JavaScript), then uses set_file to present them. When you select this plugin, a WebDialog should appear:

The user interface is still quite simple:

  • The disclosure triangle hides and shows "Help text".

  • The radio buttons let you select the number of sides.

  • The "Transparent" checkbox lets you create a transparent ruby,
    as opposed to the opaque one drawn by Draw Ruby 1.

Here, for example, is a "12-sided, transparent" ruby:

Logging, etc.

The plugin framework provides well-developed logging mechanisms.

The SketchApps loader creates a new log file at the start of each SketchUp session. The file name is created from the date and time when the session began, eg:

.../SketchUp/SketchApps_use/sa_log_files/2012.0608.133805.356856

For convenience, a symbolic link (_) points to the most recently created log file. As each session progresses, its log file is filled with a detailed record of SketchApps-related activity. This can be very useful in debugging, performance tuning, etc. Let's take a look...

The initial log entry provides overall context (eg, when the run began, what platform Ruby reported, where the user's home directory resides):

Tue Mar 06 11:39:31 -0800 2012
RUBY_PLATFORM= "i686-darwin8.10.1"
path_home=     "/Users/rdm"

Most of the succeeding log entries track method calls. The following entry, for example, tells us:

  • when the method called trace_me (0.03 seconds into the session)
  • what it said about itself ('Load_SketchApps::Loader.log_version')
  • Ruby's name for the method (log_version).
  • where trace_me was called (line 984 of load_sketchapps.rb)
  • where log_version was called (line 698, in load_sa_dir), etc.

A configuration setting (:tm_limit) limits the number of trace_me context lines. More surgically, @skip_list (defined and used by trace_me) specifies which calls to ignore (eg, '> PF_Main.indent').

   0.03 > Load_SketchApps::Loader.log_version
  log_version                     load_sketchapps.rb:984
  load_sa_dir                     load_sketchapps.rb:698
  load_sa_dirs                    load_sketchapps.rb:204
  each                            load_sketchapps.rb:195

In some cases, a method will log additional information. For example, log_version records information extracted from SketchApps Version files:

.../SketchApps/CFCL/Public/Admin/Version
  time_gmt=2012-03-06 08:16Z
  time_lcl=2012.0306.001636
  version=0.3.6

For more information, see the Plugin framework's notes on Logging and Tracing.

Further Reading

If you want to know how the Draw Ruby plugins work, see (in order) Draw Ruby 1 Internals and Draw Ruby 2 Internals.


This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r10 - 28 Jun 2012, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email