SketchUp Ruby Code Editor
Description
This code editor offers an easy 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 a complete 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.
The other reason is that I wanted it to behave a bit more like a real code editor, so I added a bit of jQuery magic to make it look good and have some additional features. I also added the excellent CodeMirror 2.0 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!
This editor was originally an extension of Jim Folz’s Web Console plugin.
At this point, this editor has the following features:
- Execute multiline Ruby code directly in SketchUp
- Open and save files
- Fast opening of large files
- Nice and clean user interface
- Tab key works as expected in editor (inserts spaces or tabs)
- Indenting of code blocks
- Dropdown with code snippets inserts snippets at cursor
- 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 reference websites
- Browser zoom
- 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
Downloads
SketchUp Ruby Code Editor v.2.0 (289.82 kB, downloaded 3188 times) - PLEASE NOTE: Download the ZIP file and unzip it into the SketchUp plugin directory (usually at C:\Program Files\Google\SketchUp\Plugins\ in Windows or /Library/Application Support/Google SketchUp/SketchUp/Plugins/ on the mac). Keep the folder structure as it is in the ZIP file. Then re-start SketchUp and look for the new menu item in the Windows menu. If you are updating, just overwrite the old version of this plugin.
SketchUp Ruby Code Editor v.2.0 (RBZ version) (289.82 kB, downloaded 100 times) - PLEASE NOTE: Download the RBZ file. Then open SketchUp (v.8 M2 and above) and go to the Preferences dialog. On the Extensions tab, select "Install Extension..." and browse to the file.
You can also find this project on GitHub.
Screenshots
Main editor window
Browser tab
Win7-style split-view of editor and SU (light UI)
Options page (dark UI)
Credits
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 2.0 extension. I am also grateful for many comments and suggestions from Dan Rathbun and others at SCF.
Lingering problems:
- Minor issues on the Mac: results don’t output correctly, initial code is not shown
- Page zoom does not work well in reference browser – just use this as a backup if the font is unreadable
- Doesn’t like to work when other code editors are running in SketchUp – Just restart SketchUp if there are problems
- Coloring sometimes needs text change to update
Revision History
- Version 2.0 (4/12/2011)
- Switched editor to use CodeMirror – sooo much better!
- Added code coloring for several languages (Ruby, HTML, CSS, JavaScript, XML, C/Java)
- Can handle large files easily
- Added bracket matching
- Added coloring changer
- Disabling run button if code is not Ruby
- Added some more options
- Added option to disable single undo
- Added color coding for SU classes
- Fixed problem with loading/saving slashes in files
- Updated jQuery and jQuery UI
- Results window is now continuous and scrolls
- Added some more code snippets to dropdown
- Added toolbar item
- Moved menu item to “Windows” menu
- Added settings file for modifications
- Added code printing - Version 1.2 (4/13/2010)
- Updated jQuery UI to v. 1.8
- Added object explorer button to show current selection details
- Added attribute explorer button for selection attributes
- Added button to show Ruby console
- Modified code a bit
- Changed buttons to images for space reasons
- Fixed keyboard access (Alt+…)
- Added pages to browser: Edges to Rubies, Ruby core and Google search
- Added basic update checking
- Enabled browser buttons again – use at your own risk…
- Waiting icon shown while code executes - Version 1.1.2 (3/8/2010)
- Removed nav buttons also for IE because they disabled code execution after a while
- Renamed some code elements
- Added wrapper module - Version 1.1.1 (2/25/2010):
- Safari-related fixes (cookies, text insert, removed back button) - Version 1.1 (2/22/2010)
- Changed webdialog internal name for compatibility
- Better looking dropdowns under Windows
- Fixed save filename preselect problem
- Better code execution and error catching (thanks to Dan Rathbun)
- Faster file loading for large files
- Added cookie-based saving of preferences (expires after 365 days)
- Added changeable user interface
- Modified some references - Version 1.0 (2/3/2010)
- First release
Next steps
- Check out my intro tutorials: SketchUp script clips #1: Setup and basic ideas, SketchUp script clips #2: Creating geometry
- Look at the SketchUp Ruby API
- Read the Automatic SketchUp book
- Discuss your projects at the SCF
-
http://alexschreyer.net Alexander Schreyer
-
Gjxiaolong88
-
Newbie
-
Newbie
-
http://alexschreyer.net Alexander Schreyer
-
tahw nikcufos
-
http://alexschreyer.net Alexander Schreyer
-
http://twitter.com/3dpt Peter Saal
-
http://alexschreyer.net Alexander Schreyer
-
http://alexschreyer.net Alexander Schreyer
-
Macgile
-
Macgile
-
http://alexschreyer.net Alexander Schreyer
-
http://alexschreyer.net Alexander Schreyer
-
Sérgio Bizello
-
Sérgio Bizello
-
pierremail.com
-
Liqun
-
Liqun
-
Liqun
-
GeniX
-
mark
-
Rod
-
eran
-
sw96500
-
http://napkinsketchup.blogspot.com/ John
-
Gerrit Hubers
-
Dan Rathbun
-
Gerrit Hubers
-
Gerrit Hubers
-
Dan Rathbun
![[as]](http://www.alexschreyer.net/blog/wp-content/themes/alex-2012/img/as.png)



