Reporting component geometry data into Ruby Console
-
A basic question I'ms sure this is but I can't figure out how to do it:
I have a component I have created (its a basic shape) that I wish to use in several sketchup models. I want to report the geometric data into the ruby console e.g. its centre point (in terms of x,y,z) once I have placed it into the model. How can I do this, given that the component has a specific name e.g. R1?
Many thanks for your help. Much appreciated
Robin
-
Hi Robin, I started working on a script that shows model info right on the screen and down in the bottom left corner. Here is a link
http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=16837
It could be adapted to also display the center of the a component if that is what you'd like. Check it out and see if that would be helpful.
Also, this script it just a minor variation of the "Query" tool that comes with SketchUp.
Chris
-
thanks for your help Chris, meant to reply sooner
but I want to see a list of components in ruby, ultimately so I can calculate the distance between two defined objects. I want to do this using code rather than measuring the distance as I ultimately want to apply a separate calculation based on the distance.
I was hoping it would take the form of:
List the components in ruby, say component_1 and component_2, listed as
component_1 [5,1,2]
component_2 [10,12,3]
etcthen I can use these points in space to do a variety of mathematical calculations
Thanks
Robin
-
Try component_instance.transformation.to_a - it returns a 16 item array that has all of the stuff you need like scaling rotation and location. You really need to use all of these to compare distances between components etc as they might be rotated, scaled etc as well as moved in XYZ...
The 16 item array has items 12,13,14 == x,y,z
.
Advertisement