Objets controlled by a webpage
16 posts
• Page 1 of 1
Objets controlled by a webpageHi all..
I am trying to write a plugin that can control Sketchup objects from a web dialog that is on a website, not a local HTML file. I see from this video, http://www.youtube.com/watch?v=FALvwBN5 ... re=related (If you fast forward to 6:08) that you can grab data off of a website and render it in Sketchup.... Does anyone out there have a sample of this code? I'd like to see it in action... I have searched for that plugin that Scott demonstrated on there, but I can't seem to find it...
Re: Objets controlled by a webpageHi Eric,
I just wanted to point out the engineering toolbox page does something similar. They have a minimal ruby plugin that is installed, which opens a WebDialog poited to their server. Then, they send some Ruby code to the dialog, and 'eval' it; but that is only one way to do it. You could have all of your callbacks defined in the plugin, for example. View the source code of the plugin, and the source of one of the HTML pages to see how it works. http://sketchup.engineeringtoolbox.com/
Re: Objets controlled by a webpageAwesome! I will check it out!
Re: Objets controlled by a webpageSo I checked that out, its a pretty neat web page.
In some of the models, you can configure options of the model right on the web page, and then insert it into Sketchup, pre-configured. There is a Javaspript that runs when you configure the model. I am confused when the actual configuring happens though.... Does the user configure the model, then the model gets sent to Sketchup, where Sketchup then receives the configuration choices from the script, the changes are made, and then the model is dropped in? (That is a long sentence, and my only guess!) Anyone else have any insights? I am just learning Ruby, and I have just about zero Java experience.
Re: Objets controlled by a webpageIf you edit their plugin and add the line just before the eval statement
Open the Ruby Console to see the Ruby code that the site is sending, and their plugin is eval'ing.
Re: Objets controlled by a webpage
So that's what I get in the Ruby console. I am assuming that these are all Ruby commands that are initiated by a Javascript that gathers all the user input from the website. I checked out the Javascript, not knowing anything about Java, its really hard to tell what's going on. Where would I go to learn how to get Java to talk to ruby? I think if I see it in its most basic example, I could build from there...
Re: Objets controlled by a webpageJavascript is not Java - completely different language.
Todd
Re: Objets controlled by a webpageYou might find something helpful about javascript/ruby interaction from the code accessible from here
Chris PS I'm interested in doing this remotely as well
Re: Objets controlled by a webpageOk, so here's what I have up and running..........
http://sketchupapi.blogspot.com/2008/02 ... y-and.html What I am a little fuzzy on here is how that "refresh" button actually sends the command to Ruby. I see part of the command in the HTML file, but I am not sure exactly how it works.... I would assume that somehow the command is created by variables being pieced together, eventually creating a command, based on user input. I think if I could just understand how the command is created in the HTML file, I could then create buttons that could do anything that I want in the web dialog....
Re: Objets controlled by a webpage
What I am fuzzy on is what you have done and really what you want to do. This is mainly because youTube and blogSpot are not available in China right now. But anyway in the forums posters normally post their code or whatever directly in the post using links for backup; this makes it easier to respond to requests.
I don't know if you are referring to my refresh function; it refreshes the web dialog content after the cursor returns from the SU display. The parts that are relevant are:
However, this interaction is not the only thing concerned with both local and remote control. Identification of entities and their properties is high on the list. I use javascript arrays to mirror their Sketchup counterparts. Simply, if you want to move an object you need to identify it, find its current location and determine the new XYZ increments in 3D space. Here is a callback that actually does the moving (mostly made from Jim's snippets):
Then of course there's rotations. It all can get a little fraught but then what we are both (I think) trying to achieve is novel (i.e. not openly technically supported, and not only about finding technical solutions).
I believe this to be true and a solid base for Sketchup to become as normal part of daily work as word processing has been. Write some more if I have read you right. Chris. Please, register (free) to access all the attachments on the forums.
Re: Objets controlled by a webpageI think you are on the right track here....
Let me outline what exactly I am trying to do, and what I have learned so far... What I want is a simple Ruby script that loads a web page right in Sketchup. I've got that worked out already.... I want models to be available on the web page. I want the user to be able to set options on the models. After the user has set options, they can insert the model into their model. I also want the web page to be able to gather information about the model (like part counts, materials, stuff like that) So far I have learned that this can be achieved through Javascript passing commands to Ruby. Exactly how that works, I am still unclear. What I would like to do is build this in its most basic form. Say a webpage with one model, with one option that can be configured, and work from there. I just don't have the technical knowledge to get even that basic example started. Once I get that, I should really be able to get a handle on things and start to build it out...
Re: Objets controlled by a webpage
OK let me come back to the detail after you have watched this short video. You could let me know if it works (I cannot see it from here) but more importantly whether the part about selecting SU versions of models from remote sites and manipulating them is closer to your concept. Tell me which parts differ. I think this is less confusing. Cheers
Re: Objets controlled by a webpagemaybe this can be interesting for you:
http://www.modelur.com/home besides that, i don't know if it is possible to load a php instead of a html file in a webdialog? If so, you can get the data from a database with php and send it to Sketchup with javascript
Re: Objets controlled by a webpageThis is basically the functionality I am trying to duplicate.....
Re: Objets controlled by a webpageScott, are you lurking out there somewhere?
Re: Objets controlled by a webpageHi Eric,
The example you cited from the SketchUp Blog has everything you need. In the html of the WebDialog there is a button:
onclick is an event that is fired when the button is clicked. When the button is clicked, the Javascript function named callRuby is executed. The string value 'pull_selection_count' is passed to the callRuby function.
callRuby shows how to pass a value from the WebDialog to the SketchUp plugin that created the dialog. The Ruby script needs a callback named 'get_data'. window.location = 'skp:get_data@' + data;
The Ruby variable action_name get the value of the Javascript variable data. Hope that helps a little.
SketchUcation One-Liner AdvertsVertex Tools for SketchUp. Take control over each vertex with this vertex editor for SketchUp.
Premium Members get 20% discount!
16 posts
• Page 1 of 1
|