This is Google's cache of http://code.google.com/apis/sketchup/docs/releases.html. It is a snapshot of the page as it appeared on Sep 1, 2010 20:05:12 GMT. The current page could have changed in the meantime. Learn more

Text-only version
These terms only appear in links pointing to this page: code google com apis sketchup docs releases html  
My favorites | English | Sign in

Google SketchUp Ruby API

Release Notes

The SketchUp API has been around in some fashion since the early days of SketchUp, and with every release we have extended its capabilities. Read below for what's been changed.

Though our adoption rate to the latest version is quite high, it can take time after a release before everyone upgrades. If you are building scripts that rely on functionality from the most recent version, be sure to check the Sketchup.version to make sure your users are able to run your script:

# You can have this sort of code in the initialization routine of your plugin.
version_required = 7.0

if (Sketchup.version.to_f < version_required) 
  UI.messagebox("You must have Sketchup " + version_required.to_s +
                " to run this plugin. Visit sketchup.google.com to upgrade.")
  return
end

  

What's new in SketchUp 7.1

New methods

Find out how many faces are in your model.

model.number_faces

 

See if a model has been georeferenced for use in Earth.
model.georeferenced?

 

Force refresh of a view. More powerful that view.invalidate because it refreshes immediately.
view.refresh

 

Take a screen grab from any WebDialog.
mywebdialog.write_image 'img.jpg'

 

  

What's new in SketchUp 7.0 M1

New methods

See what component instances are glued to a given face.

for (instance in myface.get_glued_instances) { ... }

 

What's new in SketchUp 7

Improved Script Performance

Ability to perform faster inside start_operation transactions.
operation_name = "My Processing"
go_faster = true
model.start_operation operation_name, go_faster

# Do processing here that was slow in SU6
# ...

model.start_operation commit_operation

 

Results from some real world tests, (comparing SU6 to SU7 on the same machine) once the go_faster boolean was added:

Intersect overlaps with 500 overlapping squares
28.4 seconds vs. 26.3 (~92% as long)

Make faces with 500 faceless cubes
21.7 seconds vs. 14.5 (~66% as long)

Windowizer 3.0 with Four 20'x20' windows, 12x12
16.1 seconds vs. 7.0 seconds (~43% as as long)

Windowizer 4.0 with Ten 5'x5' windows, 6x6
22.6 seconds vs 8.7 seconds (~38% as long)

Improved Web Dialogs

Addition of min/max widths.
WebDialog.min_width=100
WebDialog.max_width=300
WebDialog.min_height=500
WebDialog.max_height=600

 

Fixed Mac support for WebDialogs execute_script
WebDialog.execute_script('alert("Bug is Fixed!")');

 

New full_security mode for webdialogs (disables plugins and remote links)
WebDialog.set_full_security

 

Ability to hide home/next/back navigation icons on the Mac
WebDialog.navigation_buttons_enabled=true

 

Cleaner, hash-based syntax for initializing
my_dialog = WebDialog.new(my_settings_hash)

 

Control Scale Tool Handles

Your script can now control which scale tool handles appear when the user selects a given component.
# Disable the green and red-axes handles
# by setting bits 1 and 2 to 1.
behavior = my_component_definition.behavior
behavior.no_scale_mask = (1 << 1) + (1 << 2) 

 

Load Definitions from the Web, or Save to Disk

Ability to download a definition from URL
model.definitions.load_from_url(url, download_handler)

 

Ability to Save components to disk from the API
my_definition.save_as(path)

 

Know More About User Interactions

New methods for detecting "Component Edit" mode
users_current_edit = model.active_path
edit_mode_transform = model.edit_transform

 

Easily determine if they're running in licensed Pro
is_licensed_pro = Sketchup.is_pro?

 

New "model level" callbacks in ModelObserver
def onActivePathChanged(model) { # Detect edit mode }

 

def onPlaceComponent(instance) { # Detect placements }
def onExplode(model) { # Detect group/component explode }
def onBeforeComponentSaveAs(instance) { # Add data on save as }
def onAfterComponentSaveAs(instance) { # Then clean up }

 

Detect if they've turned off your extension via the AppObserver
def onUnloadExtension(extension_name)

 

Assorted Improvements Requested by Developers

Delete your scenes via the API
my_page.erase

 

Keep SketchUp in Synch
UI.refresh_inspectors # force complete UI update
my_definition.refresh_thumbnail # force thumb update
my_definition.invalidate_bounds # force bb update

 

Measure your groups regardless of their transform
untransformed_bb = my_group.local_bounds

 

Use middle mouse button in your custom tools
def onMButtonDown(flags, x, y, view) { # now works! }
def onMButtonUp(flags, x, y, view) { # now works! }

 

Send ruby console output to the standard out If you start up SketchUp from the command line, you can pipe to standard error and see ruby puts statements appear for you.
Sketchup.exe > myRubyLog.txt

 

Finally, we fixed a number of crashing bugs, mostly related to iterating across entities in the model.

What's new in SketchUp 6

The most substantial addition to the SketchUp 6 Ruby API are the Ruby Observer Mechanism, the Tools class, the WebDialog class, the Styles class, and the Style class.

Ruby Observer Mechanism

The Ruby Observer Mechanism is designed to allow Ruby scripts to be notified when objects change in the SketchUp application or model. For example, you can create an observer class that "listens" to when SketchUp quits and then performs some action.

Create a Ruby class of a specific observer type, such as AppObserver, override the desired methods, such as onQuit, and add an instance of the observer to the applicable objects in your Ruby script (using the add_observer method for that object). Refer to individual observer interfaces for further information.

Tools Class

The Tools class contains methods to manipulate a collection of SketchUp tools. This class is primarily used to switch between tools through the use of key or mouse actions.

WebDialog Class

The Ruby WebDialog class to create and interact with, DHTML dialog boxes, called webdialogs in this documentation, from Ruby code. For example, you can create webdialogs that are invoked from your Ruby code to display a web site, or to accept user input and use the results in your Ruby code. Styles and Style Classes The Styles class contains methods for manipulating a collection of styles in a model. The Style class contains methods for modifying information about a specific style.

Before SketchUp 6

The core 62 classes of the API were established here. Very few users are on anything before SketchUp 6, so this documentation site focuses only on SketchUp 6 and up.