Sketchup and Ruby
-
Is it possible to create a ruby script that is able to connect to a server in order to read data which will be used to move objects to a certain position in a sketchup model? If so, is there any help you can give me? Thanks!
-
Hi Allison,
Possible, yes. The amount of time and effort involved will depend largely on your familiarity with programming (specifically Ruby, HTML and JavaScript) and the SketchUp Ruby API.
Moving Groups and ComponentInstances in SketchUp is fairly straight forward. Moving "loose" geometry is slightly more complicated, but manageable. Moving is most easily done using a Transformation.
The connection to a server can be done using a WebDialog. You may be able to use the
WebDialog#post_url
method to send data to a server. The result would be a string which would replace the current contents of the WebDialog. Alternatively, you could use XMLHttpRequest in a WebDialog to retrieve data from a server, in which case the response would be just the data.Once the data is retrieved by the WebDialog, it needs to be accessed by the Ruby part of the plugin, typically using
WebDialog#get_element_value
.Sorry for being short on details, but hopefully this overview helps narrow the scope a little. Please ask if you more specific questions - there are many people willing to help here, the official group, and there's even an irc channel for live #sketchup-dev.
-
Thank you very much for your reply. Unfortunately, I do not have a lot of experience with this kind of stuff so I might need some more guidance
Advertisement