Class: SketchupExtension
Relationships | |
Inherits: | Object |
Overview
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/StairTools.rb, and the actual plugin itself would live in /Plugins/StairTools/core.rb.
You can find two example extensions that ship with SketchUp, su_dynamiccomponents.rb and su_sandboxtools.rb, under the /Plugins/ folder.
Class Method Summary
-
.new(title, path) ⇒ SketchupExtension
constructor
The new method is used to create a new
SketchupExtension
object.
Instance Attribute Summary
-
#copyright ⇒ String
rw
The copyright method returns the copyright string which appears beneath an extension inside the Extensions Manager dialog.
-
#copyright=(copyright) ⇒ String
rw
The copyright= method sets the copyright string which appears beneath an extension inside the Extensions Manager dialog.
-
#creator ⇒ String
rw
The creator method returns the creator string which appears beneath an extension inside the Extensions Manager dialog.
-
#creator=(creator) ⇒ String
rw
The creator= method sets the creator string which appears beneath an extension inside the Extensions Manager dialog.
-
#description ⇒ String
rw
The description method returns the long description which appears beneath an extension inside the Extensions Manager dialog.
-
#description=(description) ⇒ String
rw
The description= method sets the long description which appears beneath an extension inside the Extensions Manager dialog.
-
#load_on_start? ⇒ Boolean
readonly
Returns whether the extension is set to load when SketchUp starts up.
-
#loaded? ⇒ Boolean
readonly
Returns whether the extension is currently loaded, meaning the actual ruby script that implements the extension has been evaluated.
-
#name ⇒ String
rw
The name method returns the name which appears for an extension inside the Extensions Manager dialog.
-
#name=(name) ⇒ String
rw
The name= method sets the name which appears for an extension inside the Extensions Manager dialog.
-
#registered? ⇒ Boolean
readonly
Returns whether the extension has been registered via
::Sketchup
.register_extension. -
#version ⇒ String
rw
The version method returns the version which appears beneath an extension inside the Extensions Manager dialog.
-
#version=(version) ⇒ String
rw
The version method sets the version which appears beneath an extension inside the Extensions Manager dialog.
Instance Method Summary
-
#check ⇒ Boolean
Loads the extension, meaning the underlying ruby script is immediately interpreted.
-
#extension_path ⇒ String
The extension_path method returns the file system path to the extension’s outer rb file.
-
#id ⇒ String
The id method returns the Extension Warehouse ID string.
-
#uncheck ⇒ Boolean
Unloads the extension.
-
#version_id ⇒ String
The version_id method returns the Extension Warehouse Version ID string.
Constructor Details
.new(title, path) ⇒ SketchupExtension
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.
Instance Attribute Details
#copyright ⇒ String (rw)
The copyright method returns the copyright string which appears beneath an extension inside the Extensions Manager dialog.
#copyright=(copyright) ⇒ String (rw)
The copyright= method sets the copyright string which appears beneath an extension inside the Extensions Manager dialog.
#creator ⇒ String (rw)
The creator method returns the creator string which appears beneath an extension inside the Extensions Manager dialog.
#creator=(creator) ⇒ String (rw)
The creator= method sets the creator string which appears beneath an extension inside the Extensions Manager dialog.
#description ⇒ String (rw)
The description method returns the long description which appears beneath an extension inside the Extensions Manager dialog.
#description=(description) ⇒ String (rw)
The description= method sets the long description which appears beneath an extension inside the Extensions Manager dialog.
#load_on_start? ⇒ Boolean
(readonly)
Returns whether the extension is set to load when SketchUp starts up.
#loaded? ⇒ Boolean
(readonly)
Returns whether the extension is currently loaded, meaning the actual ruby script that implements the extension has been evaluated.
#name ⇒ String (rw)
The name method returns the name which appears for an extension inside the Extensions Manager dialog.
#name=(name) ⇒ String (rw)
The name= method sets the name which appears for an extension inside the Extensions Manager dialog.
#registered? ⇒ Boolean
(readonly)
Returns whether the extension has been registered via ::Sketchup
.register_extension.
#version ⇒ String (rw)
The version method returns the version which appears beneath an extension inside the Extensions Manager dialog.
#version=(version) ⇒ String (rw)
The version method sets the version which appears beneath an extension inside the Extensions Manager dialog.
Instance Method Details
#check ⇒ Boolean
Loads the extension, meaning the underlying ruby script is immediately interpreted. This is the equivalent of checking the extension’s checkbox in the Preferences > Extensions list.
#extension_path ⇒ String
The extension_path method returns the file system path to the extension’s outer rb file.
#id ⇒ String
The id method returns the Extension Warehouse ID string.
#uncheck ⇒ Boolean
Unloads the extension. This is the equivalent of unchecking the extension’s checkbox in the Preferences > 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.
#version_id ⇒ String
The version_id method returns the Extension Warehouse Version ID string.