On This Page
Description
This code editor extension offers an easy-to-use and visually appealing way to write 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 I wanted a way to edit and run SketchUp Ruby code right inside of SketchUp’s 3D modeling environment. Often this is done in an external editor, but having an internal editor allows for using both scripting and modelling concurrently – depending on your needs. The editor had to provide easy access to the Ruby coding environment and behave more like a real code editor. To accomplish this, I added a bit of jQuery (and jQuery UI) magic to make it look good and have some additional visual features (e.g. the tabs and menus). I also added the excellent CodeMirror syntax highlighting engine. This provides the editor with multi-language code highlighting, correct TAB control, find/replace, bracket matching, code folding, and many other features. Just load the plugin and give it a try to see for yourself how easy it is to use!
The other reason for this extension 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 window. Also, a dropdown below the editor contains some common code snippets that can be inserted at the current cursor position. I am also experimenting with a code-completion feature that you can invoke at any point by clicking CTRL-SHIFT. It contains SketchUp’s classes and methods.
By the way:
Check out my book, “Architectural Design with SketchUp” Chapter 7 provides an overview of Ruby scripting in SketchUp and has many tutorials for things to do with this editor.
Features:
- Beautiful and clean editor user interface with menu-based UI
- Light / dark themed editor
- Allows executing multi-line Ruby code directly in SketchUp
- Works with files of any size
- Fast opening and code highlighting of large files
- Most recently used file list
- Keyboard shortcut navigation
- Line numbering in editor
- Indenting/dedenting of code blocks
- Matching brackets, current line highlighting
- Undo/redo in editor
- Find/replace in editor (text or RegEx)
- Code folding
- Insert code snippets at cursor
- Code-completion for SketchUp classes and methods
- Automatic backup file creation
- Various options: font size, tab/space indenting
- Undo of code execution
- Single undo option for entire code
- Results window keeps track of run history
- Possibility to run external Ruby files
- Reference web browser for common websites
- Explore selection object properties and attributes
- Option for direct access to the Ruby console
- Option to edit default code snippet
- Clean printing of code
Usage
Select Window > Ruby Code Editor or open from the Ruby Code Editor toolbar.
For more detailed instructions, visit the Ruby Code Editor Manual
Did you find this extension useful?
Contribute to its development with any amount (via PayPal):
Next Steps
- Check out Chapter 7 in my book “Architectural Design with SketchUp” (more info here: http://sketchupfordesign.com/). It provides an overview of scripting in SketchUp and has many tutorials for things to do with this editor.
- Check out my basic 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 if you are interested in plugin development or want to know more about Ruby in SketchUp
- Discuss your projects on this page or at the SketchUp Forums or the SketchUcation Forums
Screenshots and Videos
Extension Terms and Conditions
BY INSTALLING, ACCESSING OR USING THIS SOFTWARE, YOU (THE USER) AGREES TO BE BOUND BY THE TERMS AND CONDITIONS AS PROVIDED BELOW.
LICENSE:
This is free software, provided under the GPL license (https://www.gnu.org/licenses/gpl-3.0.html).
(c) Alexander Schreyer, alexschreyer.net
DISCLAIMER:
THIS SOFTWARE IS PROVIDED ‘AS IS’ AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR ANY COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THIS SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS SOFTWARE.
WHERE APPLICABLE, THIRD-PARTY MATERIALS AND THIRD-PARTY PLATFORMS ARE PROVIDED ‘AS IS’ AND THE USER OF THIS SOFTWARE ASSUMES ALL RISK AND LIABILITY REGARDING ANY USE OF (OR RESULTS OBTAINED THROUGH) THIRD-PARTY MATERIALS OR THIRD-PARTY PLATFORMS.
Downloads and Installation
You can now find this extension in Trimble’s Extension Warehouse. For an easy install (and update notifications), browse to it from inside SketchUp (2013 or newer) and install it directly.
Alternative Downloads
Linked below are the installation files (RBZ and ZIP formats) for the current and some previous versions of this extension. You can also find this extension on GitHub.
- as_rubyeditor_4-3.rbz- 4.3
- as_rubyeditor_4-2.rbz- 4.2
- as_rubyeditor_4-1.rbz- 4.1
- as_rubyeditor_4-0.rbz- 4.0
- as_rubyeditor_3-2.rbz- 3.2
TIP: Installing Extensions in SketchUp
To install these files, follow the SketchUp folks’ instructions.
Revision History
- Version 4.3 (5/7/2020)
– Ruby working dir changes to file dir on load/save now
– File path shows in tab title attribute
– Added menu item to open plugin folder
– Added function and menu item to run (load) external file instead of editor
– Now prints error line numbers in feedback
– Fixed 2020 GC issue (class var for browser)
– Updated links in reference browser
– Updated UI colors to be more consistent with SU - Version 4.2 (9/5/2019)
– Fixed .to_l nil comparison issue
– Added some backcomp fixes (works down to SU8)
– Error handling for invalid filetypes
– Fixes $LOAD_PATH inclusion, now sets at code execution
– Adds proper filetype selectors to open dialog - Version 4.1 (7/18/2017)
– Resubmission to fix EW signing issue
– Minor fixes and edits
– Fixed selection reporting
– Separated selection menu
– Created new SVG icons
– Added definition attribute reporting
– Added inserting of IDs
– Added more menu tooltips - Version 4.0 (7/10/2017):
– Code cleanup
– Updated jQuery, jQueryUI, codemirror
– Updated styles
– Updated code snippets
– New menu and tab UI
– Ref browser and help windows use HtmlDialog now, also separate windows
– Fixed loading code
– Fixed recent file bug. Opens in current folder now
– Fixed printing
– Fixed preferences
– Fixed eval binding to be top level (like the Ruby Console)
– Made line wrapping default
– Added preloading of optional $LIBRARY_PATH items from preferences
– Added MRU file list
– Added quick save option
– Added undo/redo
– Added find/replace
– Added code folding
– Added ability to edit default code
– Added help window (link to website)
– Improved keyboard shortcuts
– Improved reference browser, updated links - Version 3.2 (4/25/2013):
– Reorganized files and folders - Version 3.1 (3/6/2013)
– Fixed default file bug
– Updated jQuery cookie plugin
– Fixed Tab problem - Version 3.0 (3/4/2013)
– Got rid of settings file
– Results feedback now wrapped in Paragraph
– Improved feedback scrolling
– Some CSS changes, separated CSS by theme
– Two editor themes now: ambiance and eclipse
– Updated Codemirror to 3.1
– Updated jQuery
– Updated jQuery UI
– Improved editor stability, smoother scrolling
– Set IE version number to 9 (allows for more features and better display)
– Fixed SU class highlighting and added SU method highlighting
– Added syntax highlighting for SketchUp classes and methods
– Better editor closing handling
– Changed some options for newer Codemirror
– Fixed theme color options
– Better error display
– Fixed Mac rendering of results window
– Fixed Mac default folder issue - Version 2.1 (2/26/2013)
– Uses most recently used directory for file loading and saving
– Fixed the outdated URLs in the browser
– Update checking now uses www.sketchupplugins.com - 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
Credits
This editor was originally based on Jim Folz’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 excellent Codemirror. I am also grateful for many comments and suggestions from Dan Rathbun and many others at SCF.
Show Off Your Work
Did you create something amazing with this extension? I would love to see it! You can either upload an image in the comment section below (public) or privately send it to me.