Class: SketchupExtension

Inherits:
Object
  • Object
show all

Overview

Note:

By default Extension Warehouse encrypts extensions and convert .rb files to .rbe files. Omit the file extension to let SketchUp look for both.

A SketchUp extension is a piece of software that extends the capabilities of SketchUp. It could be a new drawing tool, a content library or a way to automate a tedious and time consuming task.

The SketchupExtension handles the extension metadata, such as name, author and version, as well as a path to the main Ruby file with the actual functionality you want to add.

See Extension Requirements

See Creating a SketchUp Extension

Examples:

require 'sketchup.rb'
require 'extensions.rb'

stair_extension = SketchupExtension.new('Stair Tools", "stair_tools/core')
stair_extension.version = '1.0.0'
stair_extension.description = 'Tools to draw stairs automatically.'
Sketchup.register_extension(stair_extension, true)

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Constructor Details

#initialize(title, path) ⇒ SketchupExtension

Note:

It is recommended to omit the file extension provided in the path argument. SketchUp will resolve the file extension to .rbe, .rbs or .rb.

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.

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')

# Then be sure to register it. By passing a 2nd param of true, you're
# telling SketchUp to load the extension by default.
Sketchup.register_extension(extension, true)

Parameters:

  • title (String)

    The name of the extension

  • path (String)

    The relative path to the script that loads your plugin.

Version:

  • SketchUp 6.0

Instance Method Details

#checkBoolean

Loads the extension, meaning the underlying ruby script is immediately interpreted. This is the equivalent of checking the extension's checkbox in the Extension Manager.

Examples:

# This will register the extension, a necessary step for it to appear
# in SketchUp's Extension Manager > Extensions list
ext_c = SketchupExtension.new('Stair Tools C', 'StairTools/core')
Sketchup.register_extension(ext_c, false)

# And this will load the extension.
ext_c.check

Returns:

  • (Boolean)

    whether the load succeeded

Version:

  • SketchUp 8.0 M2

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
extension.copyright = '2008'
copyright = extension.copyright

Returns:

  • (String)

    the Extension copyright

Version:

  • SketchUp 6.0

#copyright=(copyright) ⇒ String

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
extension.copyright = '2008'
copyright = extension.copyright

Parameters:

  • copyright (String)

    The copyright to set

Returns:

  • (String)

    the new copyright

Version:

  • SketchUp 6.0

#creatorString

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
extension.creator = 'Trimble Navigation, Inc.'
creator = extension.creator

Returns:

  • (String)

    the Extension creator

Version:

  • SketchUp 6.0

#creator=(creator) ⇒ String

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
extension.creator = 'Trimble Navigation, Inc.'
creator = extension.creator

Parameters:

  • creator (String)

    The creator to set

Returns:

  • (String)

    the new creator

Version:

  • SketchUp 6.0

#descriptionString

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
extension.description = 'My description.'
description = extension.description

Returns:

  • (String)

    the Extension description

Version:

  • SketchUp 6.0

#description=(description) ⇒ String

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
extension.description = 'My description.'
description = extension.description

Parameters:

  • description (String)

    The description string to set.

Returns:

  • (String)

    the Extension description

Version:

  • SketchUp 6.0

#extension_pathString

The #extension_path method returns the file system path to the extension's outer rb file.

Returns:

  • (String)

    the file system path to the extension

Version:

  • SketchUp 2013

#idString

The #id method returns the Extension Warehouse ID string.

Returns:

  • (String)

    the Extension Warehouse ID

Version:

  • SketchUp 2013

#load_errorException?

Return the Ruby load error for an extension that failed to load.

Examples:

# broken/broken_file.rb
raise "This file raises an exception"

# broken.rb
extension = SketchupExtension.new("Broken Extension", "broken/broken_file")
extension.version = "1.0.0"
extension.description = "This extension's has an error."
Sketchup.register_extension(extension, true)

extension.load_error
# => RuntimeError

Returns:

  • (Exception, nil)

Version:

  • SketchUp 2026.2

#load_on_start?Boolean

Returns whether the extension is set to load when SketchUp starts up.

Examples:

ext = SketchupExtension.new('Stair Tools', 'StairTools/core')
puts "load_on_start? is false: #{ext.load_on_start?.to_s}"
Sketchup.register_extension(ext, true)
puts "load_on_start? is now true: #{ext.load_on_start?.to_s}"

Returns:

  • (Boolean)

Version:

  • SketchUp 8.0 M2

#loaded?Boolean

Returns whether the extension is currently loaded, meaning the actual ruby script that implements the extension has been evaluated.

Examples:

ext = SketchupExtension.new('Stair Tools', 'StairTools/core')
puts "loaded? is false: #{ext.loaded?.to_s}"
Sketchup.register_extension(ext, true)
puts "loaded? is now true: #{ext.loaded?.to_s}"

Returns:

  • (Boolean)

Version:

  • SketchUp 8.0 M2

#nameString

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
name = extension.name

Returns:

  • (String)

    the Extension name

Version:

  • SketchUp 6.0

#name=(name) ⇒ String

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
extension.name = 'Renamed Stair Tools'

Parameters:

  • name (String)

    The new name

Returns:

  • (String)

    the Extension name

Version:

  • SketchUp 6.0

#registered?Boolean

Returns whether the extension has been registered via Sketchup.register_extension.

Examples:

ext = SketchupExtension.new('Stair Tools', 'StairTools/core')
puts "My registered? is false: #{ext.registered?.to_s}"
Sketchup.register_extension(ext, true)
puts "Now registered? is now true: #{ext.registered?.to_s}"

Returns:

  • (Boolean)

Version:

  • SketchUp 8.0 M2

#uncheckBoolean

Unloads the extension. This is the equivalent of unchecking the extension's checkbox in the Extension Manager > Extensions list.

Note that technically the extension is not “unloaded” in the sense that it stops running during the current SketchUp session, but the next time the user restarts SketchUp, the extension will not be active.

Examples:

# This unloads all extensions. The next time SketchUp starts, none of
# the extensions will be active.
Sketchup.extensions.each { |extension|
  extension.uncheck
}

Returns:

  • (Boolean)

    whether the unload succeeded

Version:

  • SketchUp 8.0 M2

#versionString

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
extension.version = '5.0'
version = extension.version

Returns:

  • (String)

    the Extension version

Version:

  • SketchUp 6.0

#version=(version) ⇒ String

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

Examples:

# Create an entry in the Extension list that loads a script called
# core.
extension = SketchupExtension.new('Stair Tools', 'StairTools/core')
extension.version = '5.0'
version = extension.version

Parameters:

  • version (String)

    The version string to set.

Returns:

  • (String)

    the Extension version

Version:

  • SketchUp 6.0

#version_idString

The #version_id method returns the Extension Warehouse Version ID string.

Returns:

  • (String)

    the Extension Warehouse Version ID string

Version:

  • SketchUp 2013