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!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Sketchup and open-uri

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 636 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.
    • D Offline
      designingcrime
      last edited by designingcrime

      I am interested in using open-uri to read models directly from the internet and then import them into sketchup. I followed the instructions on this forum about swapping the ruby dll in the sketchup folder and I installed Dan's loadpaths.rb and can require 'open-uri' and the rest of ruby core/libraries. However as soon as I make use of it Sketchup crashes. I have tried ruby 187 and 186, with binary and ascii with no luck, does this happen for everyone else?

      <span class="syntaxdefault"></span><span class="syntaxkeyword">require&nbsp;</span><span class="syntaxstring">'sketchup'<br /></span><span class="syntaxkeyword">require&nbsp;</span><span class="syntaxstring">'open-uri'<br /><br /></span><span class="syntaxdefault">open</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"http://www.ruby-lang.org/"</span><span class="syntaxkeyword">)&nbsp;{|</span><span class="syntaxdefault">f</span><span class="syntaxkeyword">|<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">f</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each_line&nbsp;</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">line</span><span class="syntaxkeyword">|&nbsp;</span><span class="syntaxdefault">p&nbsp;line</span><span class="syntaxkeyword">}<br />&nbsp;&nbsp;}&nbsp;</span><span class="syntaxdefault"></span>
      
      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        Try to protect Sketchup with a begin .. rescue .. end block ??

        You should run your code within an Author namespace.

        You might try a Thread.. they are much better than they were in old v1.8.0 under SketchUp before v8.

        But basically, if the file is large, you may be causing a Stack Overflow.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          Oh and there is an Sketchup::Importer class in the API that can help things.

          Also there is the LoadHandler class, that you use with Sketchup::DefinitionList#load_from_url

          I'd suggest the latter..
          a) bring the remote model into SU as a component
          b) then place an instance
          c) explode the instance if needed
          d) save the definition as a local skp (if desired)
          e) remove the definition from the DefinitionList (if it will no longer be needed.)

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • D Offline
            designingcrime
            last edited by

            Sorry for the late reply.

            So basicly what I want to do is upload files to and from a restful api using multipart/form data that are not in sketchup format.
            ie, export obj file > upload to server > delete obj file
            or
            download stl file > import to sketchup > delete stl file

            after giving up on net stuff through ruby which all seemed to crash sketchup I started looking into accomplishing this through the web dialog with ajax. While it works for communicating with the api in other ways and solves a lot of my problems. It is still not possible to upload or download a file with out the file dialog (and for good reason) but I want something more seamless. So far the closest thing I have found is

            Link Preview Image
            GitHub - danawoodman/google-sketchup-file-downloader: [NOT MAINTAINED] A generic and reusable SketchUp Ruby C extension file downloading utility to be used within SketchUp plugins.

            [NOT MAINTAINED] A generic and reusable SketchUp Ruby C extension file downloading utility to be used within SketchUp plugins. - danawoodman/google-sketchup-file-downloader

            favicon

            GitHub (github.com)

            but it isn't working. Thanks for your help, I will keep at it and appreciate any more help
            Thanks!

            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