Download files with a SketchUp plugin
-
What I was talking about in this post specifically is a generic file downloading utility written in C that has Ruby bindings so a plugin developer could use the code in their application if they needed to download something from the web. This would be for developers only and would be added into their application and would be supplied a URL and a path to save the file.
If you want, you could modify the plugin to handle some sort of authentication, but out of the box it just supports basic downloading (not following redirects or anything). I may add this in as the need arises (or you can fork the code and add it once I release the code). It taps into the cURL library, so anything cURL (libcurl) does should be possible to add into the tool...
I'll release the code as soon as possible so people can play around with it. I am just working through some hurdles in cross-platform and SketchUp specific issues. It works fine from the command line right now.
I am building this as part of a larger project of a plugin downloading tool, which will also be released shortly. I am planning on releasing a screencast here to demo its functionality in the next week or two. I will keep you all updated on this!
Thanks for all the interest!
-
As an update to my previous post, I have the initial code on Github here:
https://github.com/danawoodman/google-sketchup-file-downloader
... please read the README file to understand what the plugin does. Not everything in the README is functional/correct but is more of a wishlist so to speak.The code currently only works from the command line like so:
cd example/ ruby test_plugin.rb
... which will download files from the web onto the local system using both of the available methods
download_file()
anddownload_files()
.Trying to load the plugin from SketchUp fails with something like:
Error: #<LoadError: /path/to/file-downloader/example/file_downloader.bundle: Failed to load /path/to/file-downloader/example/file_downloader.bundle>
This is where I am stuck and need some assistance. I'm not seeing why the plugin can't be loaded into Ruby. Generating the bundle was done by running the "src/extconf.rb" file with Ruby 1.8.6-p420 and then make.
Note that I haven't done much work on Windows as I am not yet familiar with how to build the extension to work on Windows. If anyone out there has experience in this area, please feel free to fork the code and make changes or send me a message with what needs to be done to accomplish this.
This is my first C extension so I am sure I am doing things wrong, if you have some suggestions, please let me know! Really hoping someone with more C extension experience than me can help contribute!
Cheers,
Dana -
Have you looked at TBD's C-Extension project?
https://github.com/TBD/OpenSUP/tree/master/SUExt -
@thomthom said:
Have you looked at TBD's C-Extension project?
https://github.com/TBD/OpenSUP/tree/master/SUExtYes, I have. It was written for use on Windows and even after modification all I can get is a "Failed to load" error, just like the issue I'm coming across with the file downloader tool.
I've tried to set up a really bare-minimum C extensions to load into SU (for the Mac) but have thus far failed. If anyone can offer a pointer as to why a "Failed to load" error would be thrown, I would be much appreciative!
Cheers,
Dana -
removed the x64 version and now it crashes with EXC_BAD_ACCESS in Init_file_downloader. will keep you updated on debug progress.
-
@unknownuser said:
removed the x64 version and now it crashes with EXC_BAD_ACCESS in Init_file_downloader. will keep you updated on debug progress.
Glad you're looking into it TBD, I could use the help of someone with more experience!
-
here is what I did to make it work:
-
remove the x64 version from makefile - you can check with
otool -hv file_downloader.bundle
-> cputype I386 -
link to the correct libruby.1.dylib (1.8.7 in my case as I upgraded Sketchup Ruby framework) - check with
otool -L file_downloader.bundle
-> current version 1.8.7
-
-
I really wish I understood the things required to compile correctly. I've compiled a couple of C-Extension, but only at the grace of TBD and AdamB who helped me out getting the setup to work. But I have no idea how or why...
Can anyone recommend resources to understand this?
-
@unknownuser said:
here is what I did to make it work:
-
remove the x64 version from makefile - you can check with
otool -hv file_downloader.bundle
-> cputype I386 -
link to the correct libruby.1.dylib (1.8.7 in my case as I upgraded Sketchup Ruby framework) - check with
otool -L file_downloader.bundle
-> current version 1.8.7
You got it to work in Mac? That's great! Is there any chance you could send me the Makefile (or send me a Pull request on Github) so I can see where you removed the x64 bits. I couldn't find anything in the Makefile (generated by the extconf.rb file) that had any reference to x64. Thanks TBD!
-
-
@thomthom said:
I really wish I understood the things required to compile correctly. I've compiled a couple of C-Extension, but only at the grace of TBD and AdamB who helped me out getting the setup to work. But I have no idea how or why...
Can anyone recommend resources to understand this?
Once I wrap my head around this stuff, I will be writing up a few articles on the subject. I'll post links when I get them done
-
ishboo: pull request sent. also added my 1.8.7 bundle in /build
thomthom compiling is like a black box where you throw a bunch of files and expect another bunch of files. you need to know the parameters used (mostly how to include headers and libs and output formats) from the help files. also wikipedia entry on compilers is a good start for an overview.
also use a file monitor [procmon(Win) and opensnoop(OSX)] when things go wrong - it saved me a lot of time when files were not found (looking in wrong directories) or wrong files were used.
-
@unknownuser said:
thomthom compiling is like a black box where you throw a bunch of files and expect another bunch of files. you need to know the parameters used (mostly how to include headers and libs and output formats) from the help files. also wikipedia entry on compilers is a good start for an overview.
Headers and libs are one thing. But it's all the paramters, the output format and compiler settings that I have no idea of how it works. I've tried looking for tutorials - but found nothing that made me any wiser.
-
` %(#4000BF)[C:\Program Files\Microsoft Visual Studio 8\VC\bin>nmake /?
Microsoft (R) Program Maintenance Utility Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.Usage: NMAKE @commandfile
NMAKE [options] [/f makefile] [/x stderrfile] [macrodefs] [targets]Options:
/A Build all evaluated targets
/B Build if time stamps are equal
/C Suppress output messages
/D Display build information
/E Override env-var macros
/ERRORREPORT:{NONE|PROMPT|QUEUE|SEND} Report errors to Microsoft
/G Display !include filenames
/HELP Display brief usage message
/I Ignore exit codes from commands
/K Build unrelated targets on error
/N Display commands but do not execute
/NOLOGO Suppress copyright message
/P Display NMAKE information
/Q Check time stamps but do not build
/R Ignore predefined rules/macros
/S Suppress executed-commands display
/T Change time stamps but do not build
/U Dump inline files
/Y Disable batch-mode
/? Display brief usage message]` -
@unknownuser said:
The point is that you can do it from a Web dialog (via XMLHttpRequest), but sometimes you may want to check 'silently' whether something has changed on the web.
In this case, the WebDialog could be opened outside of the visible area of the screen and sized to a minimum.
wd = UI;;WebDialog.new wd.set_position(-1000, -1000) wd.show
I think folks would welcome a simpler workflow without being asked where to save the file first. A single button to install/upgrade a plugin followed with a reminder to close and restart SketchUp.
-
Plus, WebDialogs capture focus when they are displayed - which can be an annoyance if they pop up out of screen without the user' knowledge.
-
Is there a Windows build in sight?
Advertisement