@unknownuser said:
... I checked with the ruby console, and I found an error for "invalid model url"
Because the test your running is not how the plugin is going to run later. I made a comment in an earlier post (perhaps over at Google Groups,) about how the URL link would stay the same, EXCEPT for the skp filename. [see below]
But for simplicity of testing on your local machine, set up the following folders starting from your root directory (and yes, Windows doesn't care if a folder is named "www.sketchthis.net"):
C:/www.sketchthis.net/Downloads/Gallery/catagory
put test.skp in the catagory folder, along with it's test.png thumbnail
put the gallery.html (now called TEST2.html) webpage in the Gallery folder
the plugin ruby script should be in the Sketchup Plugins folder (for testing, later it can go in a subfolder called Plugins/SketchTHIS.)
Below, when you read the webbased URLs, for testing, replace "http://" with "file://C:/"
@unknownuser said:
I had the model in the same directory as the web page, and I assumed that is where it would be looked for.
No. Ruby always looks in the current Ruby working directory. Ruby does not use the Windows PATH environment variable.
Webpages are easiest if you use a <BASE> url tag, then they will start a file search from that. So plan on using a <BASE> tag in your Gallery webpage, and a Ruby Constant named BASEURL in your module, so it does not need to be passed back and forth. It CAN be passed once (so you have the option of moving things around on your website, without needing to redistribute the plugin.)
@unknownuser said:
... However, it also occured to me that it might need to go in the same folder as the plugin, so I tried that, and still no dice...
No the plugin is client-side. The models will be in a Gallery subfolder on your website.
@unknownuser said:
... Here is the link I am using to try to send my model into Sketchup (the one that generates the "invalid model URL error):
<a href="#" onclick="window.location='skp:download_model@test.skp'">Download Model</a>
OK the problem is, you will have 3 (three) parts to the URL: BASEURL, Catagory (a Gallery subfolder name,) and skp filename.
In your HTML <HEAD> section, you'd have this:
<BASE id='baseURL' href="http://www.sketchthis.net/Downloads/Gallery/"/>
In your HTML <BODY> tag, you'd have this:
<BODY id='body' onload="init();">
After your BODY end tag:
%(#804000)[</BODY>
<SCRIPT>]
%(#8000BF)[function init() {
window.location='skp:set_baseURL@'+document.getElementById('baseURL').href;
// any other init tasks
}]
%(#804000)[</SCRIPT>
</HTML>]
So the links (which will likely be thumbnail images rather than text <A> links,) would look like this:
<IMG href="catagory/test.png" onclick="window.location='skp:download_model@'+'catagory/test.skp'">Download Model test.skp</a>
It's also likely you'd want these IMG links to be auto generated by Javascript or PHP tags, from whatever model files are in a given catagory subfolder.
Then in your Ruby WebDialog SketchTHIS.create_dialog method:
You'd change the set_url:
EDIT: Change the entry point for the Gallery, for future freedom of changing website folder heirarchy, without needing to redistribute the plugin. The entry page is a small redirect page, which we'll call "go_gallery.html" that loads whatever the Gallery page is, from whatever it's current location is within the website. (Was hardcoded to a specific URL to "gallery.html")
@dlg.set_url('http://www.sketchthis.net/go_gallery.html')
You'd add another callback:
@dlg.add_action_callback('set_baseURL') { |dlg, args| SketchTHIS::BASEURL=args }
and change this callback:
EDIT: + (string concat) was << (string append), in error
@dlg.add_action_callback('download_model') { |dlg, args| modelURL = SketchTHIS::BASEURL + args Sketchup.active_model.definitions.load_from_url(modelURL) }
@unknownuser said:
To Dan... Yes, I did copy the file locations right out of Firefox. Those URL's are going to actually be on my webserver. They do work, why, I am not sure, but they do.
Well, FireFox has nothing to do with Sketchup WebDialogs (they use MSIE on PC, and Safari on Mac.) Client-side-like pathnames may not be best for server-side folder heirarchy. You already have a "Downloads" folder which can be the Gallery "top" folder, or as in the example above you can have a "Gallery" sub-folder of "Downloads", and in that the gallery.html webpage that gets loaded into the Sketchup WebDialog. Beneath that folder, can be catagorical folders holding skp models and their png thumbnails. The user would click on catagory buttons to see the image lists from the subfolders.
@unknownuser said:
Also, about the module situation, after doing some more reading, I think I am starting to understand the benefit of making this into a module. I am not going to go there just yet because I just need to get this thing working, then I can worry about making it "neater".
As far as putting the plugin in a special directory, I want to do that, I am just trying to tackle one thing at a time.
It's not about 'neatness' Eric, these things are fundamental, they need to be done at the start, not later, so you don't paint yourself in a corner, or have problems like your having.
As far as where the client-side plugin goes, you don't really have a choice because of how Sketchup works. It looks in the Plugins heirarchy for plugins. Users will NOT want you installing them anywhere else, most especially not in their User/Documents folder heirarchy.
So you WILL have a plugin registration script in the Plugins folder, that (if turned on by the user,) loads your plugin from the Plugins/SketchTHIS folder.