Ruby Code Editor
This code editor plugin offers an easy-to-use and visually appealing way to write and modify Ruby scripts directly within SketchUp.
Ruby Code Editor

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.

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
  • 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
  • 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.

You can also find this extension on GitHub.

More Info and Help:

http://www.alexschreyer.net/projects/sketchup-ruby-code-editor/

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.

Reviews

Mobdro is an application that finds free video clip streams https://imobdro.com latest application news, Evaluations installation on different movies application.

Marko L's picture

Thank you!

your Android smartphones/tablets. If the download web link for Maker Liker machineliker offering by the followers on your updates. These comments give.

alexschreyer's picture

I am finishing version 4.0 with a bunch of nice changes. Anyone here interested in beta testing it, especially on a Mac? Here's the link:

https://www.dropbox.com/s/fene4y5ue2q9m8g/as_rubyeditor_4-0-Beta.zip?dl=0

alexschreyer's picture

Version 4.0 is available now!

flyer50@libero.it's picture

HI Alexander

I cant use the program and, as you suggested in other post, I delete and reinstall the version 3.2 .
I do this many times but from the "about" menu I always see the description "version 3.1"

Opening the new file "as_rubieditor.rb" I see that the version is really 3.2, although the description in th emenu "about" indicates the old version 3.1

best regards
flyer50

alexschreyer's picture

You can ignore the about window's version. I have to fix that one in the next release (coming soon).

Wise F.'s picture

Hello Alex,
Thanks for posting this extension. It is very useful and has a lot of potential.
A Ruby editor is certainly needed within Sketchup. Even if other external alternatives (like Netbeans, Eclipse, etc.) are available, I like having a kind of "native editor" within Sketchup.
One thing that is not working for me and I really miss is the ability to do a functional text find/search with a replace option. The one I get in your code editor malfunctions all the time.
So, I have to re-open the code in another code or text editor to so the search-and-replace. When I press Alt+F in your code editor, I get a find UI but it doesn’t have a replace option and it only finds (and highlights) instances of the word I am trying to find within the visible part of the code. Even if I press the next-button, it does not find further instances. Sometimes it is even grayed out, when I know with certainty that there are other instances of the word sections of the code outside the visible part.
Anyway, please, keep developing it or open-source it, as it is very useful in its current form and has great potential.
One more thing. Is there a chance we could see Python amongst the language editors available in your editor?
Cheers
Raoul

Minh N.'s picture

After join Ruby world for a week, I found this wonderful plugin. Thanks, Alex!

Hello,
I just install Editor which worked the first time.
I close and reopen Sketchup 2015, and when I want to launch Ruby editor, nothing occurs, and Ruby console display the following. And I am not a Ruby expert ;)

Error: #
C:/Users/xxx/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:225:in `split'
C:/Users/xxx/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:225:in `initialize'
C:/Users/xxx/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:522:in `new'
C:/Users/xxx/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:522:in `block in '
SketchUp:1:in `call'

Line #225 is : @snip_dir = @snip_dir.split("/").join("\\") + "\\"

Julian S's picture

Hi Alex, I think I found an error in your RCE (3.2), when it is loaded and you go to > Options > Get Updates > Check for updates it returns "You have the latest version (3.1)" which isn't correct as the latest version (which was downloaded moments before and installed) is 3.2.

alexschreyer's picture

Thanks for pointing this out. This particular mechanism has been superseded by the EW update checking, so I will remove it in the (now quite overdue) next version.

Chin Huat T's picture

Hi Alex,

Great editor. I like it. However It is a pain to remember the plugins directory where all ruby scripts are stored.
Appreciate if you can provide an option to "remember" the plugins directory in the options menu.

As an example, my plugins directory is
"C:\Users\ChinHuat\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Plugins"
and it is very long and difficult to remember.

Thanks and Regards,
TCH

Thank you Alex for the quick answer
I could not find how to send the screenshot.
The windows lists
<<
•Ruby Code Editor
•Reference Browser
•Options
•About
...
insert at cursor: ruby
...
untitled.rb
...
1
mod = Sketchup.active_model # Open model
2
ent = mod.entities # All entities in model
3
sel = mod.selection # Current selection
running...
Cleared the editor
>>

any idea?

alexschreyer's picture

Looks like the window doesn't show JavaScript. I am guessing you are on Windows.
Try this: Open Internet Explorer on your computer and make sure you are running the latest version (IE 11). Update if necessary. http://windows.microsoft.com/en-us/internet-explorer/which-version-am-i-...

Amira M.'s picture

I'm having the same problem too. The script is not loading when I choose an .rbz file

alexschreyer's picture

Are you trying to load an RBZ file into the editor? That won't work because the RBZ file is a compressed (binary) file. If you want to explore any of the RBZ extensions, rename the RBZ file ending to ZIP and then open it. Take any RB files out of the compressed folder. You can then load them into any editor. It's a great way to learn coding.

Amira M.'s picture

Thank you so much for you prompt reply. I'm all new to this and I want to edit a line in an RBZ file for plugin I've downloaded.
I made the file .zip file (compressed it) but it didn't work, also I tried just renaming the file as .zip and opening it but it didn't open, so I didn't get to take the .rb files out of the folder. sorry this seems dumb.

I have the same problem also. I'm using sketchup 2015

Dear Alex
Sorry, wonderful tool, but I do have a problem installing it:
sketchup2016 and plugin installed from within sketchup/window/preferences.
But not the nice code-highlighted editor appears later (window/ruby code editor) but an ugly whithe window titled "Ruby Code Editor" with "insert at cursor:"/"ruby" in it.
But I cannot see any coding windows.
Can you please help????
Thanks!!!

alexschreyer's picture

That's odd. Any chance you could get me a screenshot? You can upload one on my website in the comments (see link above). It may have to do with your Internet Explorer version. Update it to the latest version.

I don't know how I would have been able to learn Ruby without a decent environ to play in. This app is a must. Thanks!

alexschreyer's picture

Great to hear!

W R's picture
W R

Hi, Alex, thanks for the great editor!
Is there a way to change the key combination for auto-complete? The ctrl+space conflicts with the input method on windows machine, would like to find a easy way to change the shortcut key if possible.

alexschreyer's picture

Good idea. I logged it as a feature request for my next iteration.

mark p's picture

this is a must have for anyone starting to model with Sketchup. Nothing like having ruby right at your fingertips. I especially recommend this for schools so kids can see that coding, visualizing, and designing all work together.

Bryan B's picture

Worked great the first time I used it . Will not appear again. It is listed in Windows and the tool bar is there but no editor.

alexschreyer's picture

I haven't heard of that before. Do you have any other editors installed? What happens if you uninstall and reinstall the RCE? Still the same?

3skeng©'s picture

Great Plugin, very helpful. Thank you, Sebastian

Abubakar I.'s picture

I install it the way you wrote, but it haven't work.

Pattilyn C's picture

Successfully installed!

I was experiencing invisible folders due to Maverick operating system.

Looking forward to learning how to use Ruby Editor now!

Pattilyn C's picture

I'm sorry this is a dumb question but I'm really struggling to install the Plugin. I'm using a Mac but also a student version of Sketchup 2014 so just wondering if there are restrictions based on this version that are preventing me from installing?

I have followed your instructions but no luck.

Any help most appreciated.

WOFF3D's picture

I just started to work with it. Some small questions. 1) Is it possible to keep RCE on top of SketchUp. Everytime I click on SketchUp window I have to find RCE underneath. 2) When I use puts I don't see the output in the results window. Am I doing something wrong.
Thanks for your great work.

Krgds Charles

so beautiful! thx!

Tyrone M's picture

Very nice plugin, please consider adding find or search function.

Consider for MAC OSX users the addition of the following to keep toolbar from always loading up at startup:

instead of this code
--------------------------
as_rce_tb.show

use this code
--------------------------
 state = as_rce_tb.get_last_state
 if(state==TB_VISIBLE)
   as_rce_tb.restore

Scott Lininger's picture

What a fantastic plugin! Highly recommended for any SketchUp Ruby Developer. It is also very nicely structured, so if you'd like to see a good way to subclass SketchUp's WebDialog, take a peek at the source code. Thanks, Alex!

alexschreyer's picture

Thanks, Scott! Very glad you like it.

7725 users
Size:
608.61 KB
Version:
Ruby Code Editor (4.1); July 18, 2017
Number of Views: 
67086
OS Compatibility: 
Languages: 
Popularity: 
Extensions: 7
I am a Senior Lecturer at the University of Massachusetts and author of the book "Architectural Design with SketchUp". My favorite topics are SketchUp, AEC-CAD/BIM, Wood Engineering, Web Design, and Photography.