Download files with a SketchUp plugin
-
-
Agreed, that's cool!
Chris
-
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?
-
@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... -
@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?
-
As a generic down-loader it will work through something like a webdialog, where the url-side contains files that can be downloaded; but once you get into a public-type web-site like SCF then the whole browser coding possibilities are setup to protect the user, and it will always asks for a 'save' confirmation via an unavoidable dialog to prevent virus invasions etc. In a database-type system what is picked 'on-screen' is merely a link to a db and the file is elsewhere - the thing that's then downloaded in 'protected', you'll probably never get the direct link to the very file itself, which lies under layers of protection to prevent backtrack hacking through html folder-paths and thereby potentially allowing the getting of all such files en mass...
As part of a 'tool' that allowed you to download plugins 'direct' from SCF you'd need to have paths available to the tool from a db ? How is the arrival folder to be determined ? Like 3dWarehouse lets you download/use SKP files from clicking links, but then you still need to select a save path etc... -
TIG,
You are perfectly right. Downloading by program (specially binary files) is something where we could go to an uncontrolled path.
What could be useful however is a Ruby method to download text file (like a public HTML page), usually to a temporary directory, just the time to read it.
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.
Otherwise better invoke the traditional "download dialog box" of the browser.
I have this function in LibFredo6 check for Update, but I did not enable it for several reasons:- it may not work depending on your local security configuration
- on Mac, it does not put the focus on the small download window, except the very first time
But the main reason is that I think it is always preferable that the user goes to the plugin web page and then have an opportunity to read the text and instructions, rather than to download 'blindly' files.
As an illustration, I have enabled the download file function for the plugin RemoveLonelyVertices (you should see now a small blue arrow). I am intersted in knowing what users get when clicking on it.
Fredo
-
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]`
Advertisement