Load_from_url
-
Made a small test:
First to a non-existsing URL:
model.definitions.load_from_url( 'http://www.thomthom.net/foo.skp' ) Error: #<IOError: (eval):155:in
load_from_url': Invalid component URL>
(eval):155
(eval):155`Then to an existing URL:
model.definitions.load_from_url( 'http://www.thomthom.net/bar.skp' ) #<Sketchup::ComponentDefinition:0xfcdf7bc>
So it looks like your URL is simply wrong. Remember that URL's some times need special characters - for instance spaces are translated to %20 etc.
If the URL fixed? Or is it generated? If it's generated - have you outputted it for inspection? Have you tried the same URL in a browser?
-
@thomthom said:
Made a small test:
First to a non-existsing URL:
model.definitions.load_from_url( 'http://www.thomthom.net/foo.skp' ) Error: #<IOError: (eval):155:in
load_from_url': Invalid component URL>
(eval):155
(eval):155`Then to an existing URL:
model.definitions.load_from_url( 'http://www.thomthom.net/bar.skp' ) #<Sketchup::ComponentDefinition:0xfcdf7bc>
So it looks like your URL is simply wrong. Remember that URL's some times need special characters - for instance spaces are translated to %20 etc.
If the URL fixed? Or is it generated? If it's generated - have you outputted it for inspection? Have you tried the same URL in a browser?
Thanks for doing that.
Have attached bridge.rb.
Will do some more url sleuthing.
-
How do you trigger the "product" callback?
-
I somehow managed to trigger it - clicking on "Kitchen".
Output I got was this:
true "Kitchen,0,0,0" "Kitchen.skp" "http://glasier.hk/Product/Kitchen.skp" Error: #<IOError: Invalid component URL> c:/Users/thm.ARC/Desktop/bridge/bridge.rb:68:in
load_from_url'
c:/Users/thm.ARC/Desktop/bridge/bridge.rb:68:instart'
When I type
http://glasier.hk/Product/Kitchen.skp
into my browser I get a 404. So the problem is that your URLs leads to non-existing resources. -
@thomthom said:
How do you trigger the "product" callback?
function suStart(node){ var fn, params; fn = nset[node].Label; //WC in trial params = [fn,0,0,0].toString(); window.location = "skp;product@" + params; }
-
@thomthom said:
...
When I type
http://glasier.hk/Product/Kitchen.skp
into my browser I get a 404. So the problem is that your URLs leads to non-existing resources.
-
Also ...
-
It's your server configuration you need to address. Not your plugin.
-
@thomthom said:
It's your server configuration you need to address. Not your plugin.
Beyond my ken!
Anything like
dialog.allow_actions_from_host(url)
?If not what does that do?
Any more help much appreciated!
Thanks
-
@chrisglasier said:
Anything like dialog.allow_actions_from_host(url)?
It's nothing related to SketchUp. As you can see - you cannot even access the files from a web browser. Don't know what you have to do because it all depend on what type of server and configuration you have.
@chrisglasier said:
If not what does that do?
webdialog.allow_actions_from_host(url)
is allowing websites to send commands to SketchUp, viawindow.location = "skp:command@params";
type of commands. -
Chris if it's a UNIX server, you would need to have the file permissions set correctly using chmod.
-
Thanks T & D.
-
I put skp files into a zip file which I manually download and extract to a subdirectory named in bridge.rb. I can then open each component in its location.
Do you think it possible to automate the downloads and their extraction into a named folder? I have searched but have difficulty getting to grips with the results.
If I could do that then I could demonstrate the benefits of collecting skps and json data from multiple trusted/vetted sources. If required complex js/php analysis of the data to set design criteria for example could be done say in Chrome browser before the url is plopped into the web dialog to see what the various options look like.
Please bear with me!
-
@chrisglasier said:
Do you think it possible to automate the downloads and their extraction into a named folder?
Well the new rbz interface will do this. The "subfolder" must be wrapped inside the zip, and currently will only end up beneath the "plugins" dir. (Google has not yet given us the option to have the extraction go someplace else.)
The other option is that if a user has a full Ruby install, the standard Ruby lib
Zlib
can be used to extract from several different archive formats.
Then Ruby also has some other file moving modules, as well as theDir
class.Another option is to use platform dependent shell commands (backtick delimited, or
%x
delimited strings.) -
@dan rathbun said:
@chrisglasier said:
Do you think it possible to automate the downloads and their extraction into a named folder?
Well the new rbz interface will do this. The "subfolder" must be wrapped inside the zip, and currently will only end up beneath the "plugins" dir. (Google has not yet given us the option to have the extraction go someplace else.)
Thanks but I am not sure I understand how this automates the extraction to the plug in folder. It seems you have to click the install button in extensions?
I was thinking to click a js link in my url (standalone or in wd) to pick up a plain zip file from any trusted url and extract it into one or more named local folders. Dreaming perhaps!
-
There are new API methods with the latest v8M2 to extract files/subfolders [into Plugins] from zip/rbz files.
However, if you already have ways of extracting them, then the moving to their new locations can be done with vanilla Ruby Dir and File commands... -
@chrisglasier said:
Thanks but I am not sure I understand how this automates the extraction to the plug in folder. It seems you have to click the install button in extensions?
see: Sketchup.install_from_archive
(because we have no "slappin' ya' upside da' head" emoticon)
@chrisglasier said:
I was thinking to click a js link in my url (standalone or in wd) to pick up a plain zip file from any trusted url and extract it into one or more named local folders. Dreaming perhaps!
Your link or html button can execute a callback to Ruby that does the install, moves files around etc.
-
@tig said:
There are new API methods with the latest v8M2 to extract files/subfolders [into Plugins] from zip/rbz files.
However, if you already have ways of extracting them, then the moving to their new locations can be done with vanilla Ruby Dir and File commands...Or the extended library
FileUtils
FYI.. there is a Pure Ruby (beta) edition of the
Zlib
library that is cross-platfrom (no need to deal with compiled so/dll, Ruby version, compiler versions, etc. etc.) It is by Park Heesob (who is involved with Daniel Berger's win32-api project.)
Advertisement