@pptoppto said:
thanks!
@3dita said:
AWESOME utility!!! working just like a 3ds max fundamental tool!!
Must have, congrats
You're both welcome! Glad you like it!
@pptoppto said:
thanks!
@3dita said:
AWESOME utility!!! working just like a 3ds max fundamental tool!!
Must have, congrats
You're both welcome! Glad you like it!
@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
@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 I386link 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!
@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!
@thomthom said:
Have you looked at TBD's C-Extension project?
https://github.com/TBD/OpenSUP/tree/master/SUExt
Yes, 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
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()
and download_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
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 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...
@bwerst said:
So next question what's the fastest way to show the board feet information. I've found in the parts object where its being stored and calculated. Do I need to change the renderers? Ideally, it would be great if there was a checklist to show/hide the extra columns such as area, volume, and board feet that are stored in the part object.
I've got a rough board/square foot measurement to show up in the Web Page format. It shows a rounded up board feet/square foot measurement for each table. Probably only useful for Batched cutlists...
It doesn't yet show up in CSV but would be trivial to add (not sure I will add this though... needs more thought). Check out the renderers.rb file for "class HTMLReneder" and the method "section_footer" so you can see what is going on.
You can download the update here:
https://github.com/danawoodman/Google-Sketchup-Cutlister-Plugin/zipball/master
I'm sure I'm missing something but I hope this will help you a bit in using Cutlister. I am planning on a few big updates and improvements in the near future when I have the time
Cheers
@jim said:
Hi Dana,
Thanks for the utils, they are a nice addition to SketchUp.
Just a note - Toolbar image sizes are 24x24 px for the large size and 16x16 px for the small size. SketchUp does a poor job of resizing your 32x32 icons on the toolbar which is why they don't look as nice as they should. Tool cursors are expected 32x32.
You're right Jim, I'll have to get around to changing them for the next release.
@unknownuser said:
[This was a question from Dana]
On Windows, executing some external commands via the method
system(cmd)
provokes a short appearance of a black window. This depends on the kind of command you execute indeed. Note that this does not happen on Mac.One method I use is to invoke the command via the Windows Shell scripting (actually VBScript).
> #Execute a command without the black screen
> def run_shell_command(cmd)
> fvbs = File.join ENV["TEMP"], "temporary.vbs"
> File.open fvbs, "w" do |f|
> f.puts "Set WshShell = CreateObject(\"WScript.Shell\")"
> f.puts "WshShell.Run \"#{cmd}\", 0"
> end
> system "wscript #{fvbs}"
> end
>
If anyone knows a more direct way to achieve it, thanks for feedback
Fredo
Fredo: Thanks for the code. I've gotten a working usage of it on a Virtual Machine but it seems to be running very slow, even slower than with the dialogs popping up. Is this expected? Could it be a bug in my code?
@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 sizecons
β’ must code itHow 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
@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!
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
Wow, thank you everyone for your responses!
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'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?
TIG: Would this be possible with a .zip file or a stream of text/image files? How well is this supported on Win/Mac? Have you tried this within SketchUp before? I thought about doing such a thing but felt it may not be an elegant/robust enough solution... Would love to hear your opinion.
Fredo: The tool I am working on will allow users to browse the website (which is pretty much done) with a trimmed down interface, allowing them to view plugins, read release notes and reviews, check ratings and more; all within SketchUp. I already have most of this working and I also have most of the core features to install tools into isolated directories, check for and install updates, allow for uninstall (e.g. deletion of the code) and listing of installed plugins working. I of course need to do more tweaking/testing and improvement but I have a good chunk working now.
On another note, I have been trying to use your Traductor.download_from_url url, local_file
method but cannot seem to get it to work. I have gotten it to return the path to where the file should be located but there is no file there. Is there something I am doing wrong:
Traductor.download_from_url 'http://www.somesite.com/something.zip', '/path/to/something.zip'
... which is returning nil
I have tried using curl locally on my Mac similar to how your tool works:
curl -o something.zip http://somesite.com/something.zip
... which works just fine. So I am not clear what I am doing wrong...
Also, are you saying base64 encoding of a zip file would fail with JavaScript?
Thanks again for all the responses!
Dana
I've been attempting to find a way to download a file from a website within a SketchUp plugin but cannot find a decent solution.
Specifically, I am looking for:
Does anyone know how this can be accomplished?
Hey all,
I am embarking on the dark road of C extensions and had a few questions in regard to how to go about writing one:
Any direction/tips/links on these issues would be greatly appreciated!
Cheers,
Dana
Excellent tool, I can see a ton of uses for it. Great idea!
@unclebim said:
:thumb: That is what would matter most for us here in Europe I think. Thank you ishboo for your contribution with this plugin!
Thanks!
Yes, metric will be the next thing I work on!
Cheers,
Dana W