19.12.2016 Views

Architectural_Design_with_SketchUp

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix D<br />

Creating Your Own Plugins<br />

The following is a basic template to get you started <strong>with</strong> writing your own plugins for <strong>SketchUp</strong>.<br />

Even if you don’t want to publish your plugin, it might be useful sometimes to “install” a<br />

script you created in <strong>SketchUp</strong> using this convenient method.<br />

RBZ Plugin File Structure<br />

The RBZ file format was introduced in Maintenance Release 2 of Version 8. Packaging a plug in<br />

this way allows users to easily install it from <strong>SketchUp</strong>’s Preferences dialog.<br />

To enable use of the RBZ-installer functionality, all files that make up a plugin must be<br />

packaged in one single compressed file (note that the RBZ file format is simply a renamed ZIP<br />

file). The following is a minimal sample file structure. You can add as many other files and<br />

folders as necessary for your plugin. The entire contents of the compressed file (including<br />

the folder structure) is copied into <strong>SketchUp</strong>’s Plugins folder on installation and the plugin is<br />

made available immediately.<br />

my_plugin.rbz (compressed file)<br />

|<br />

|— my_plugin_loader.rb<br />

|<br />

|— my_plugin (directory)<br />

|<br />

|— my_plugin.rb<br />

As a reference: <strong>SketchUp</strong>’s default plugin installation folder can be found here (replace<br />

version number <strong>with</strong> current major version):<br />

Windows: C:\Program Files\Google\Google <strong>SketchUp</strong> 8\Plugins\<br />

Mac: /Library/Application Support/Google <strong>SketchUp</strong> 8/<strong>SketchUp</strong>/Plugins/<br />

TIP<br />

Plugin Template Structure<br />

It is a good idea to (1) use <strong>SketchUp</strong>’s extension system (so that plugins can be turned on<br />

and off by the user) and (2) wrap your plugin in its own Ruby Module (to prevent conflicts<br />

291

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!