sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Download files with a SketchUp plugin

    Scheduled Pinned Locked Moved Developers' Forum
    47 Posts 11 Posters 6.9k Views 11 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.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      @ishboo said:

      Dan: Requiring users to have their own full Ruby install is not ideal for this purpose as the tool is meant to be general purpose and widely usable without configuration.

      I am a firm believer in users always having a full Ruby install, regardless of platform, to support all plugins, not just your plugin manager.

      @ishboo said:

      I'd love it if we had a full Ruby to play with on both OSs, but sadly that is not the case... Is there a way to have a bundled install of Ruby within the plugin? Say an .exe for windows and a bundle for Mac? Is this doable?

      All Macs come with a full Ruby install "out of the box", the issue is however, that the full install is in most cases a much newer version and patch level than the old framworkized initial release of Ruby v1.8.5 that Mac Sketchup uses. (Upgrading the Sketchup Mac edition to load a newer Ruby is problematic. It seems that on Mac, [and I am not an expert in this area,] that the Sketchup Ruby API extensions are statically linked against this old 1.8.5-p0 Ruby framework. It would be nice if Mac users could force Sketchup to load a newer ruby version, but as a worst case, perhaps the missing 1.8.5 library files could copied into the framework dirs.)

      Windows however is simple. There is already a one-click installer for Ruby 1.8.6-p287, the version & patch level that Sketchup 8 uses. (It's also simple on Windows to cause older Sketchup versions to load this version by replacing the msvcrt-ruby18.dll in the Sketchup dir with the file that ships in the bin dir of the full Ruby install, or the file that comes with Sketchup 8.)
      Ruby (v1.8.6-p287) Windows One-Click Installer (25Mb)
      I think the size of the installer is too large to bundle into your manager zip... better to just have the installer as a separate required download (which you could mirror on your website.)

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • fredo6F Offline
        fredo6
        last edited by

        Dana,

        The method is anyway based on Curl, which, on Mac, is part of the system utilities.
        My code is just encapsulating it (and making it work for Windows) but it is not yet finished on Mac, as I did not really test it.

        If curl -o something.zip http://somesite.com/something.zip, then try to make it a string cmd and execute it from Ruby via system(cmd) [note: you may need to put extra double quotes around the arguments) and tell me if it works.

        Fredo

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

          Fredo,

          the best I can offer for 10.5.8 (at least) is

          system("curl -O http://homepage.mac.com/johnboundy/filechute/homer%20instal.dmg.zip
          open /homer%20instal.dmg.zip")
          
          system("osascript -e 'tell application \"Finder\"' -e 'activate' -e 'end tell'") 
          

          this downloads the zip, opens it (in the HD:) and then brings it to the front by opening Finder...
          You can then click it to open for instal.

          Locally, I can open the .dmg fully with a single script in Terminal, but not through SU

          I'll have a play later.

          BTW: the file is just Jim's 'homer' [yell if you object Jim] in a wrapper if you want something to test download

          john

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 Reply Last reply Reply Quote 0
          • I Offline
            ishboo
            last edited by

            Fredo: Thank you! This is what I needed! Finally got downloading working on both Mac and PC. For Mac I ended up doing something like:

            system("curl -L -o \"/home/user/somefile.txt\" http://www.somesite.com/somefile.txt")
            

            Using the -L option follows redirects so if the download link was something like http://www.somesite.com/download/?id=123 it would follow the download redirect, which comes in handy. Having the local filesystem URL in quotes helped, and wasn't needed for the URL. On windows, instead of calling curl I called the path to the curl_win.exe file that Fredo has in LibFredo6 3.7.

            I finally have a working plugin installer tool! It downloads and install plugins from my website as well as from local files. It even handles uninstall with a restart. I'll update when I have something for people to try out!

            Dan: I agree all users "should" have a full Ruby install but the harsh reality is that they don't and many users are not technical enough to install it. My tool needs to work "out of the box" and the curl solution allows for this. Also, the fact that the Ruby installer could not be bundled with my app is another reason I don't think that route will work for me. Thanks you for the suggestions though, I am sure they will come in handy in the future.

            driven: Thanks for that. Luckily I found a workaround for downloading/extracting a zip, but I like the trick.

            Cheers,
            Dana

            SketchUp plugin marketplace: http://extendsketchup.com/

            1 Reply Last reply Reply Quote 0
            • tbdT Offline
              tbd
              last edited by

              @unknownuser said:

              It would be nice if Mac users could force Sketchup to load a newer ruby version

              I "upgraded" my Sketchup Ruby to 1.8.7 using this trick

              I think it is more easy to create an extensions (PC/Mac) which downloads the file from a given URL (with redirect and authentification) than packaging curl

              SketchUp Ruby Consultant | Podium 1.x developer
              http://plugins.ro

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

                @ishboo said:

                Dan: I agree all users "should" have a full Ruby install but the harsh reality is that they don't and many users are not technical enough to install it.

                Does not make sense.

                If many users are not technical enough to run a one-click installer executable, how are they technical enough to install your package?

                And.. didn't they succeed in downloading and installing Sketchup's one-click installer executable despite their lack of technical skill?

                I'm not here much anymore.

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

                  And by the way.. pik (which is the Win32 equivalent of RVM,) uses the 7za.exe command line executable. (The file must be in the path environment var, or use an absolute path.)

                  There's also a DLL version. It's Free OpenSource, under GNU LPGL.

                  Command line versions are available for Win, Unix, Linux, OSX, etc.
                  http://www.7-zip.org/download.html

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • I Offline
                    ishboo
                    last edited by

                    @dan rathbun said:

                    Does not make sense.

                    If many users are not technical enough to run a one-click installer executable, how are they technical enough to install your package?

                    And.. didn't they succeed in downloading and installing Sketchup's one-click installer executable despite their lack of technical skill?

                    It does make sense. I was not talking about Window's one-click install but the hacking required to get it working on a Mac.

                    Also, having to require users to download a 25mb file and install it just to use my plugin is not acceptable in my eyes. I want this plugin to work on most systems by default, without any mucking around and dependencies.

                    @dan rathbun said:

                    And by the way.. pik (which is the Win32 equivalent of RVM,) uses the 7za.exe command line executable. (The file must be in the path environment var, or use an absolute path.)

                    There's also a DLL version. It's Free OpenSource, under GNU LPGL.

                    Command line versions are available for Win, Unix, Linux, OSX, etc.
                    http://www.7-zip.org/download.html

                    So this would be to extract a zip then? I got around local extraction because I do that server side and pull each file in manually, but would be interesting in case I change my mind or need that behavior in another plugin.

                    @unknownuser said:

                    I "upgraded" my Sketchup Ruby to 1.8.7 using this [url=http://stackoverflow.com/questions/3333163/how-to-update-ruby-in-google-sketchup:38tqxa52]trick[/url:38tqxa52]

                    Thanks for the link, if I need to upgrade I'll have to check that out.

                    @unknownuser said:

                    I think it is more easy to create an extensions (PC/Mac) which downloads the file from a given URL (with redirect and authentification) than packaging curl

                    Do you have an example of an extension that would download a file from the web? I asked around and searched quite a lot to no avail. Also, by extension, do you mean a C/C++ extension (I'm assuming so...)?

                    It seems like curl works fine for this use case (since it is working already and requires only a few lines of code and a very small .exe file). If there is a good reason to go with something else I'd love to hear it... Why do you think it is more easy to create an extension?

                    Thanks for all your replies guys!

                    SketchUp plugin marketplace: http://extendsketchup.com/

                    1 Reply Last reply Reply Quote 0
                    • tbdT Offline
                      tbd
                      last edited by

                      pros for C/C++ ruby extension
                      • you can download directly to memory without the need to save to disk first
                      • no need to spawn to command line - faster
                      • provide a progress bar / cancel without the need to poll curl output
                      • smaller package size

                      cons
                      • must code it 😉

                      SketchUp Ruby Consultant | Podium 1.x developer
                      http://plugins.ro

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        @unknownuser said:

                        pros for C/C++ ruby extension
                        • you can download directly to memory without the need to save to disk first
                        • no need to spawn to command line - faster
                        • provide a progress bar / cancel without the need to poll curl output
                        • smaller package size

                        cons
                        • must code it 😉

                        How easy/hard is it to make it cross-*platform?

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • I Offline
                          ishboo
                          last edited by

                          @thomthom said:

                          @unknownuser said:

                          pros for C/C++ ruby extension
                          • you can download directly to memory without the need to save to disk first
                          • no need to spawn to command line - faster
                          • provide a progress bar / cancel without the need to poll curl output
                          • smaller package size

                          cons
                          • must code it 😉

                          How easy/hard is it to make it cross-*platform?

                          I'd also like to know this. Also would love to know if there is any open-source code or tutorials out there about how to make such an extension.

                          I am lacking in C knowledge and doing something like this would be a rather difficult task for me at this point.

                          Any info would be appreciated.

                          Cheers,
                          Dana

                          SketchUp plugin marketplace: http://extendsketchup.com/

                          1 Reply Last reply Reply Quote 0
                          • I Offline
                            ishboo
                            last edited by

                            As an update to this post, I am near complete with a Ruby C extension that downloads a file or files within a Ruby plugin that works on Mac and Windows. I will be releasing it as an open-source project and will post again when it is available. It is strait-forward to use and uses the powerful cURL (libcurl) library. Till then...

                            SketchUp plugin marketplace: http://extendsketchup.com/

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              👍 👍

                              Thomas Thomassen — SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • fredo6F Offline
                                fredo6
                                last edited by

                                @ishboo said:

                                As an update to this post, I am near complete with a Ruby C extension that downloads a file or files within a Ruby plugin that works on Mac and Windows. I will be releasing it as an open-source project and will post again when it is available. It is strait-forward to use and uses the powerful cURL (libcurl) library. Till then...

                                Very good. Thanks in advance.

                                Fredo

                                1 Reply Last reply Reply Quote 0
                                • jason_marantoJ Offline
                                  jason_maranto
                                  last edited by

                                  👍

                                  I create video tutorial series about several 2D & 3D graphics programs.

                                  1 Reply Last reply Reply Quote 0
                                  • TIGT Offline
                                    TIG Moderator
                                    last edited by

                                    👍 👍

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • Chris FullmerC Offline
                                      Chris Fullmer
                                      last edited by

                                      Agreed, that's cool!

                                      Chris

                                      ☀ 😄 👍

                                      Lately you've been tan, suspicious for the winter.
                                      All my Plugins I've written

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

                                        Thanks Dana. Just curious, since there are so many plugins posted here and people need to be registered and logged-in to download them, will your plugin handle the login?

                                        Hi

                                        1 Reply Last reply Reply Quote 0
                                        • thomthomT Offline
                                          thomthom
                                          last edited by

                                          @jim said:

                                          Thanks Dana. Just curious, since there are so many plugins posted here and people need to be registered and logged-in to download them, will your plugin handle the login?

                                          ?
                                          We're talking about generic downloader here I think. Not a plugin downloader...

                                          Thomas Thomassen — SketchUp Monkey & Coding addict
                                          List of my plugins and link to the CookieWare fund

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

                                            @thomthom said:

                                            We're talking about generic downloader here I think. Not a plugin downloader...

                                            What's the difference? Maybe my question should have been: Could the downloader be used to download plugins for SCF where a user is required to be logged in to have access to the file?

                                            Hi

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

                                            Advertisement