sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Access Run Ruby Gems and Other Ruby Code From SU Ruby

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 404 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      billbell52
      last edited by

      As I understand it Sketchup has a builtin Ruby Interpreter and they had added some classes to manipulate objects in Sketchup.

      Say I wanted to interface to an Oracle db that contained info on size and placement of objects. I already have a standard Ruby install that interfaces with Oracle. It also has several Gems installed that perform mathematical calcs on geometric objects. How can I link the 2 Ruby environment? Can I add some path info to reference the other Ruby install from SU Ruby? Can I reference the SU classes in my standard Ruby install? It there some Gem I can install to invoke SU ruby commands from a standard Ruby install? Can I add a standard Ruby install to SU?

      Thanks for any insight on this.

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Welcome Bill,

        The first thing to try is append the $LOAD_PATH from the installed Ruby environment to the SketchUp environment.

        If you run IRB in your installed Ruby, and enter $LOAD_PATH ($: for short), you might see something like this:

        
        ["c;/ruby/lib/ruby/site_ruby/1.8", "c;/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt", "c;/ruby/lib/ruby/site_ruby", "c;/ruby/lib/ruby/1.8", "c;/ruby/lib/ruby/1.8/i386-mswin32", "."]
        
        

        But in SketchUp, the $LOAD_PATH might be something like this:

        
        ["C;/Program Files/Google/Google SketchUp 7/Plugins", "C;/Program Files/Google/Google SketchUp 7/Tools", "C;/Program Files/Google/Google SketchUp 7/Plugins/Podium", "C;/Program Files/Google/Google SketchUp 7/Plugins/Podium", "C;/Program Files/Google/Google SketchUp 7/Plugins/ruby"]
        
        

        So in your SketchUp script, append the $LOAD_PATH from the installed Ruby to the $LOAD_PATH in script.

        
        
        # Script.rb
        $LOAD_PATH.concat(["c;/ruby/lib/ruby/site_ruby/1.8", "c;/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt", "c;/ruby/lib/ruby/site_ruby", "c;/ruby/lib/ruby/1.8", "c;/ruby/lib/ruby/1.8/i386-mswin32", "."])
        
        

        Then see if you can require the needed libraries.

        You might need to install version 1.8.0 of Ruby because that is what SketchUp uses... although I have been able to copy the msvcrt-ruby118.dll from my installed Ruby to my SketchUp directory without obvious problems. (Rename original first, of course.)

        Hi

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement