My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google SketchUp Ruby API

SketchupExtension

class

Parent: Object

Introduction

SketchUp 6.0+

The SketchupExtension class contains methods allowing you to create and manipulate SketchUp extensions. Extensions are Ruby scripts that can be loaded and unloaded using the Extension manager (Extensions panel of the Preferences dialog box). Generally you should register your ruby scripts as an extension to give SketchUp users the ability to disable it through the user interface.

The idea here is to take the ruby script that actually creates your functionality and place it in a folder somewhere outside of the /Plugins folder, most commonly a subdirectory like /Plugins/MyExtension. Then you create a new ruby script inside the /Plugins directory that will set up the extension entry and load your original script if the user has your extension turned on.

Here is an example extension loading script. For this example, the following code would be saved in /Plugins/loadStairTools.rb, and the actual plugin itself would live in /Plugins/utils/stairTools.rb.

     # Create an entry in the Extension list that loads a script called
     # stairTools.rb.
     require 'sketchup.rb'
     require 'extensions.rb'

     stair_extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
     stair_extension.version = '1.0'
     stair_extension.description = "Tools to draw stairs automatically."
     Sketchup.register_extension stair_extension, true

You can find two example extensions that ship with sketchup, dynamiccomponents.rb and sandboxtools.rb, under the /Tools/ folder that sits next to the /Plugins/ folder.

Methods

The copyright method returns the copyright string which appears beneath an extension inside the Extensions Manager dialog.

Returns:

copyright
the Extension copyright
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 extension.copyright = "2008"
 copyright = extension.copyright

SketchupExtension.copyright=SketchUp 6.0+

The copyright= method sets the copyright string which appears beneath an extension inside the Extensions Manager dialog.

Arguments:

copyright
The copyright to set

Returns:

copyright
the new copyright
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 extension.copyright = "2008"
 copyright = extension.copyright

SketchupExtension.creatorSketchUp 6.0+

The creator method returns the creator string which appears beneath an extension inside the Extensions Manager dialog.

Returns:

creator
the Extension creator
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 extension.creator = "Google, Inc."
 creator = extension.creator

SketchupExtension.creator=SketchUp 6.0+

The creator= method sets the creator string which appears beneath an extension inside the Extensions Manager dialog.

Arguments:

creator
The creator to set

Returns:

creator
the new creator
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 extension.creator = "Google, Inc."
 creator = extension.creator

SketchupExtension.descriptionSketchUp 6.0+

The description method returns the long description which appears beneath an extension inside the Extensions Manager dialog.

Returns:

description
the Extension description
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 extension.description = "My description."
 description = extension.description

SketchupExtension.description=SketchUp 6.0+

The description= method sets the long description which appears beneath an extension inside the Extensions Manager dialog.

Arguments:

description
The description string to set.

Returns:

description
the Extension description
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 extension.description = "My description."
 description = extension.description

SketchupExtension.nameSketchUp 6.0+

The name method returns the name which appears for an extension inside the Extensions Manager dialog.

Returns:

name
the Extension name
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 name = extension.name

SketchupExtension.name=SketchUp 6.0+

The name= method sets the name which appears for an extension inside the Extensions Manager dialog.

Arguments:

name
The new name

Returns:

name
the Extension name
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 extension.name = "Renamed Stair Tools"

SketchupExtension.newSketchUp 6.0+

The new method is used to create a new SketchupExtension object. Note that once the extension object is created, it will not appear in the Extension Manager dialog until your register it with the Sketchup.register_extension method.

Arguments:

title
The name of the extension
path
The relative path to the script that loads your plugin.

Returns:

extension
the new Extension object
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"

SketchupExtension.versionSketchUp 6.0+

The version method returns the version which appears beneath an extension inside the Extensions Manager dialog.

Returns:

version
the Extension version
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 extension.version = "5.0"
 version = extension.version

SketchupExtension.version=SketchUp 6.0+

The version method sets the version which appears beneath an extension inside the Extensions Manager dialog.

Arguments:

version
The version string to set.

Returns:

version
the Extension version
 # Create an entry in the Extension list that loads a script called
 # stairTools.rb.
 extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
 extension.version = "5.0"
 version = extension.version