Here’s a simple overview of important items to remember when developing and distributing a SketchUp plugin. Where I have already written about the topic or other sources exists it’s been linked. Otherwise it’s a just simple brief description where a topic eventually will be written.
Stability
- Ensure base classes, modules and methods are not modified
- Wrap everything in a unique namespace
- Ensure the plugin can run from any file location
- Ensure plugins, especially beware observers, doesn’t mess up the undo stack
- Ensure observers doesn’t interrupt operations
- Keep support files grouped in a folder, not flat in the Plugins root
Behaviour
- Keep the Undo stack clean (Important!)
- Let SketchUp handle units
- Respect hidden entities (hidden entity or hidden layer) and locked flag
- Ensure you display correct material name
- Remember not all definitions are components
- Groups can have multiple instances, make the edited group unique
Performance
- Disable UI refresh whenever possible
- Ensure all validation procs does absolute minimum
- Ensure observers does absolute minimum
- Avoid Entity.typename, use Entity.is_a?
- Avoid string manipulation, use Symbols
- Use SketchUp’s API methods whenever possible
- Use bulk operation methods
- Use shortcut friendly action names
- Cache calculations
- Hashes are your best friend