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, trueYou 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.
The copyright method returns the copyright string which appears beneath an extension inside the Extensions Manager dialog.
Returns:
# 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
The copyright= method sets the copyright string which appears beneath an extension inside the Extensions Manager dialog.
Arguments:
Returns:
# 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
The creator method returns the creator string which appears beneath an extension inside the Extensions Manager dialog.
Returns:
# 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
The creator= method sets the creator string which appears beneath an extension inside the Extensions Manager dialog.
Arguments:
Returns:
# 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
The description method returns the long description which appears beneath an extension inside the Extensions Manager dialog.
Returns:
# 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
The description= method sets the long description which appears beneath an extension inside the Extensions Manager dialog.
Arguments:
Returns:
# 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
The name method returns the name which appears for an extension inside the Extensions Manager dialog.
Returns:
# 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
The name= method sets the name which appears for an extension inside the Extensions Manager dialog.
Arguments:
Returns:
# 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"
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:
Returns:
# Create an entry in the Extension list that loads a script called # stairTools.rb. extension = SketchupExtension.new "Stair Tools", "utils/stairTools.rb"
The version method returns the version which appears beneath an extension inside the Extensions Manager dialog.
Returns:
# 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
The version method sets the version which appears beneath an extension inside the Extensions Manager dialog.
Arguments:
Returns:
# 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