SketchUp Ruby Code Editor
Description
This code editor allows creating and modifying Ruby scripts within SketchUp. These scripts can be used to create geometry, add functionality or add data within the SketchUp 3D modeling environment.
This editor is an extension of Jim Folz’s excellent Web Console plugin.
I created this version of the editor mainly for two reasons: One is that when I code, I permanently need to look up documentation. To fix this, 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. While it still isn’t a full-fledged code editor (with syntax highlighting, autocomplete etc.), it is actually quite functional for smaller projects. In the 1.1 version, you can also set your user interface preference (light, dark or blue).
At this point, this editor has the following features:
- Execute multiline Ruby code directly in SketchUp (from Web Console)
- Open and save files (from Web Console)
- Reasonably fast opening of large files
- Nice and clean user interface (using jQuery UI)
- Line indentations are preserved when opening files
- Tab key works as expected in editor (inserts spaces or tab)
- Dropdown with code snippets inserts snippets at cursor
- On save, a backup file can be created
- Text size dropdown selects editor font size
- Line highlighting in editor
- Undo button next to run button
- Reliable editor dialog resizing
- Tab and accesskey navigation
- Reference web browser for common reference sites
- Browser zoom
- Style changer for user interface
- Buttons to explore selection object properties and object attributes
- Button for direct access to the Ruby console
- Version update checking
Downloads
SketchUp Ruby Code Editor v.1.2 (217.31 KB, downloaded 890 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). Then re-start SketchUp and look for the new menu item in the Plugins menu. If you are updating, just overwrite the old version of this plugin.
Screenshots
Main editor window with snippets dropdown shown
Main editor window with dark UI
Browser tab with links shown
Win7-style split-view of editor and SU
Options page (dark UI)
About page
Credits
In addition to Jim’s original code and whatever I added and modified, this editor uses the jQuery and jQuery UI libraries. I am also grateful for comments and suggestions from Dan Rathbun and others at SCF.
Revision History
- 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
![[as]](http://www.alexschreyer.net/blog/wp-content/themes/alex-2009/img/as.png)







Hi,
I'm working on a AZERTY keyboard and in order to insert [ , ] , | and # I need acces to the ALT Gr key. Pressing the ALT Gr key in the code editor, results in a "pop-up" input field for some reason, preventing correct input in the editor.
I'm working on Win 7 64 bit with Google Sketchup 6
Thanks for letting me know. That was an attempt at a code completion that I apparently hadn't removed. I'll take it out in the next version. In the meantime, look into the ui.js file and remove or comment (or modify) this block:
// Autocomplete – Show input when CTRL SHIFT combination is pressed
var isCtrl = false;
var crPos = 0;
$(document).keyup(function (e) {
if(e.which == 17) isCtrl=false;
}).keydown(function (e) {
if(e.which == 17) isCtrl=true;
if(e.which == 18 && isCtrl == true) {
crPos = $('#console').getSelection().start;
$('#autoplete').show();
$('#autoplete_txt').focus();
return false;
}
});
Cheers, Alex
THis is great!!!! It makes those lookups to the Ruby and API so easy.
Nice work, thank you, works fine on windows 7 64bit.
Good to hear!
Good work!
Thanks for the tool!
Great tool !
Work well in my system: Windows XP, IE7, Sketchup Pro 7.0
Great idea!
To get your sample code to work I had to add "Math." to sin function to prevent the error:
(eval):9:in ‘initialize’: undefined method ‘sin’ for #<WebConsole:0x6e6d5d8>
Interesting. It works fine for me. Are you on a Mac?
Dan, it (whatever you may call it (not a SU-tool though!)) was mentioned to show up in the Tools menu. Thats why my insignificant remark. Of course I found it where it should be. And later I checked the code where it is send to.
I can't catch up with you guys but at least that I could figure out.
Cheers.
OK.. gotcha.Sorry.. my bad! (I missed the typo.)
Alexander,
Hi, I'm Gerrit Hubers / Wo3Dan on the SU forums. Thanks for making this script/editor. Hopefully it's going to help me in getting to know how to write (simple) ruby scripts for SU. I liked Jim's Web Console for it was integrated in SU's environment. For me that's essential for understanding what happens when, when trying/altering snippets. So I'm really excited about this tool!!!
One verrrrrrry small remark from a simple futur user. Your tool shows up in the 'Plugins' folder in SU, not in the 'Tools' folder.
Thanks again,
Gerrit
Edit: Your tool shows up in the 'Plugins' menu in SU, not in the 'Tools' menu in SU.
Oops! Just a typo. Thanks for catching it. Of course the tool appears in the "Plugins" menu.
Because it's not a Tool. (Like a Pencil or Protractor.) It's a Utility (and in the Ruby subcatagory.)