This code editor plugin offers an easy-to-use and visually appealing way to create and modify Ruby scripts directly within SketchUp. These scripts can then be used to create geometry, add functionality or add data within the SketchUp 3D modeling environment. The SketchUp Ruby API provides an extensive set of functions to automatize SketchUp in many ways or create scripted, computational geometry.
I created this editor mainly for two reasons: One is that when I write code, I permanently need to look up documentation. To make this easier, I added a bunch of reference webpages to a browser in a tab. Also, a dropdown above the editor contains some common code snippets that can be inserted at the current cursor position. Version 3.0 also introduces a code-completion feature that you can invoke at any point by clicking CTRL-SHIFT. It contains SketchUp’s classes and methods.
The other reason I wrote this as a plugin that works right inside of SketchUp is that I wanted it to give easy access to the Ruby coding environment and behave a bit more like a real code editor. To accomplish this, I added a bit of jQuery magic to make it look good and have some additional features. I also added the excellent CodeMirror 3.1 syntax highlighting engine. This provides the editor with multi-language code highlighting, correct TAB control, bracket matching and many more features. Just load the plugin and give it a try to see for yourself!
At this point, this editor has the following features:
- Execute multiline Ruby code directly in SketchUp
- Open and save files of any size
- Fast opening of large files
- Nice and clean user interface
- Tab key works as expected in editor (inserts spaces or tabs)
- Indenting/dedenting of code blocks
- Dropdown with code snippets inserts snippets at cursor
- Code-completion for SU classes and methods (click CTRL-SPACE to activate)
- On save, a backup file can be created
- Text size dropdown selects editor font size
- Line numbering in editor
- Matching brackets highlighting
- Undo in editor
- Undo (of code execution) button next to run button
- Single undo for entire code or multiple undo steps
- Results window keeps track of history
- Reliable editor dialog resizing
- Tab and accesskey navigation
- Reference web browser for common websites
- Browser zoom (a little buggy!)
- Style changer for user interface
- Buttons to explore selection object properties and object attributes
- Button for direct access to the Ruby console
- Clean printing of code
- Version update checking
This editor was originally an extension of Jim Foltz’s Web Console plugin.
In addition to Jim’s original code and whatever I added and modified, this editor uses the jQuery and jQuery UI libraries. Syntax highlighting is provided by the Codemirror 3.1 extension. I am also grateful for many comments and suggestions from Dan Rathbun and others at SCF.
Select Window > Ruby Code Editor or open the Ruby Code Editor toolbar.
You can also find this plugin on GitHub.
More Info and Help: