Pages

Plugin: Ruby Toolbar

This Windows-only plugin creates a Toolbar for controlling the Ruby Console

It can open and close the Ruby console, clear the console, load a ruby script, reload the last script, and browse the Plugins folder.

Updated Jan 11, 2011
  • Remembers most recently used folder and file between SketchUp sessions.
If anyone is feeling generous, I could really use a set of nice-looking button images in a consistent theme. I threw the current images together from free images I found online.


----

Update Jan 5, 2011
  • Changed Toolbar name from "Ruby Console" to "Ruby Toolbar"  ( TT )
  • Wrapped in additional module namespace RubyToolbar
  • Made to use SketchUp's Extensions Dialog
  • Use $suString.GetString to get proper "Ruby Console" name string.
  • Better check if TB was previously visible.
  • Use UI.start_timer to restore Toolbar.
 ----


Installation
  • Download rubytoolbar.zip
  • un-zip the archive to your Sketchup/Plugins folder, and re-start SketchUp. The extracted files should be located as in the following image:


Installation files relative to the Plugins folder:




21 comments:

  1. there's something that does not work..
    the hide function, after opening don't work and if I hit the clear buttom ùi get these messages in ruby console:

    Error: # TypeError: no implicit conversion from nil to integer
    C:/Programmi/Google/Google SketchUp 6/Plugins/rubytoolbar.rb:94:in `call'
    C:/Programmi/Google/Google SketchUp 6/Plugins/rubytoolbar.rb:94:in `moveConsole'
    C:/Programmi/Google/Google SketchUp 6/Plugins/rubytoolbar.rb:66:in `clearConsole'
    C:/Programmi/Google/Google SketchUp 6/Plugins/rubytoolbar.rb:167
    C:/Programmi/Google/Google SketchUp 6/Plugins/rubytoolbar.rb:167:in `call'

    ReplyDelete
  2. Massimo,

    I suspect the name of the Ruby Console in your language is different than in my English version of SketchUp. For me, it's "Ruby Console". For French, it's "Console Ruby"

    If you can send me the title of the Ruby Console (screenshot) I can add it to the plugin.

    Also, this is a plugin for windows and won't work on a Mac.

    ReplyDelete
  3. Thanks so much for posting / writing this!!

    Jiang

    ReplyDelete
  4. Hello Jim,

    the same Error in the German version of SketchUp. Ruby Console called "Ruby-Konsole". Please add it to the plugin.

    Thanks and greetings from the sunny side of Germany, called Hamburg

    ReplyDelete
  5. Ok, johann from Hamburg - I have added "Ruby-Konsole". Let me know if it works. Thanks for the report.

    ReplyDelete
  6. Hello Jim,

    the hide function and the clear button don't work.
    But when I change in Line 16 (when "DE" -> when "de") it works perfect.

    Johann

    ReplyDelete
  7. Hy jim! nice job there! But I get an error when trying to clear console.
    I use english language for SU.
    below is the error.

    Error: TypeError: no implicit conversion from nil to integer>
    C:\Program Files\Google\Google SketchUp 6\Plugins\rubytoolbar.rb:96:in `call'
    C:\Program Files\Google\Google SketchUp 6\Plugins\rubytoolbar.rb:96:in `moveConsole'
    C:\Program Files\Google\Google SketchUp 6\Plugins\rubytoolbar.rb:68:in `clearConsole'
    C:/Program Files/Google/Google SketchUp 6/Plugins/rubytoolbar.rb:175
    C:/Program Files/Google/Google SketchUp 6/Plugins/rubytoolbar.rb:175:in `call'

    ReplyDelete
  8. newone, please copy and paste this line in the Ruby Console, and report back.

    Sketchup.os_language

    Also, what is the title of the Ruby Console window when open?

    ReplyDelete
  9. Sketchup.os_language
    en-US

    The title is "Ruby Console" so it should work normaly.

    ReplyDelete
  10. Now it's working and I haven't done anything(almost :P). I added a new when statement for en-US, but I deleted it... it was a stupid try... because you covered in else the "Ruby Console" case- Maybe some strange invisible character was in the line. This script is written on PC under XP?
    But I noticed some strange behaviours...
    If clear the console and I close it, when I reopen it, the text is still in console. It doesn't open a clear console.
    The most interesting thing is that if I open the console fro Window menu it opens with its default size. If I use your button it opens rememberingt its last size (modified by user). So I'm wondering if that error is not related about registry reading... or some global variable. I took a quick look in your script but I couldn't find something strange. Anyway I'm a beginner in programming and ruby in special ;)

    ReplyDelete
  11. I also noticed the screen does not stay cleared, but the clearing is done by the win32api library. It's just the way it works and I never lokked into why.

    ReplyDelete
  12. In opening SketchUp, i got a window with the following message:
    "Load Errors

    Error Loading File rubytoolbar.rb
    No such file to load - Win32API"

    After searching, no win32Api on my computer. It is clear i have to install this library. I'm turning around on internet and i'm not sure of what i have to install.. Perhaps a little help from you dear Jim! Simon

    ReplyDelete
  13. never mind Jim,
    I finally found by myself.

    Everything is explained
    "Here"

    (i didn't know this "seem-to-be" excellent SU wiki )

    And if you don't want to install the the entire Ruby system, you can find Win32API.so (last version i guess) Here:
    Win32APi.so


    Rubytoolbar.rb works well for me now!
    :-)simonbonnet (SCF simonlebon)

    ReplyDelete
  14. Simon, I missed your post, or maybe just forgot about it... I checked and you are correct - I made a mistake and did not include win32api.so in the download. I will fix that now. Thanks for the report.

    ReplyDelete
  15. Hy, it's a very nice plugin! But... I just changed on Windows 7 and it seems to not work. It doesn't recognize Win32API.so:

    Error Loading File rubytoolbar.rb
    126: The specified module could not be found. - C:/Program Files/Google/Google SketchUp 7/Plugins/win32api.so

    Can anyone post a solution? Thanks.

    ReplyDelete
  16. Windows 7 problem with win32API.so (see my previous post) is solved as follows:
    -I downloaded win32api gem from http://rubygems.org/gems/win32-api/versions/1.4.6-x86-mswin32-60
    -I used api.so from win32-api-1.4.6-x86-mswin32-60\lib\win32 directory
    -edited rubytoolbar.rb:
    Win32API.new changed in API.new
    *don't forget to rename api.so in win32API.so, or change the require statement.

    I don't know why it did not worked with the original file, maybe is a matter of characters encoding.

    ReplyDelete
  17. Hi Jules (and everyone),

    I done all your tips for windows 7 , the RUBYtool bar is displayed but the clear console function (or display console function) does not work and return this error :

    #
    C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/rubytoolbar/rubytoolbar.rb:41:in `findWindow'

    The error appeared at each API.new...

    I put the api.so in the Plugin directory and change the name from Win32API.new in API.new. I change the require statement in require "api", I add the line include Win32, but nothing change, do you have an idea??? Thanks

    ReplyDelete
  18. Hi Jim
    I've downloaded and installed the ruby toolbar based on your mentioned tips, but when I run sketchup I get this message:
    Error Loading File D:/Program Files/Google/Google SketchUp 7/Plugins/rubytoolbar/rubytoolbar.rb
    No such file to load -- Win32APIError Loading File rubytoolbar.rb
    No such file to load -- Win32API

    and as a result there is no ruby console in my plugins menu.

    wish you can help me with this.
    my sketchup version: 7.1.6860 on Windows Vista

    ReplyDelete
  19. Jim,

    I downloaded the Ruby Toolbar zip and extracted it to my plugins folder. I got the error:

    Error Loading File C:/PROGRA~2/Google/GOOGLE~3/Plugins/rubytoolbar/rubytoolbar.rb
    no such file to load -- Win32APIError Loading File rubytoolbar.rb
    no such file to load -- Win32API

    I have tried all the fixes I read in your comments section including installing Ruby On Rails etc. To no avail. Do you have any new ideas for a solution? I am running Window 7.

    Joe...

    ReplyDelete
  20. AnonymousJune 15, 2012

    In self.clearConsole please add an condition, example:
    moveConsole(@rect) if @rect

    because @rect is nil (in my SU).

    Regards, Sigi

    ReplyDelete
  21. Hi there -
    Has anyone found a workable solution to the error:

    Error Loading File C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/rubytoolbar/rubytoolbar.rb
    no such file to load -- Win32APIError Loading File rubytoolbar.rb
    no such file to load -- Win32API

    I have downloaded the most recent .zip toolbar file and tried the other solutions posted here. I appreciate any help you can provide. Thanks!

    ReplyDelete