How to get real position of vertex
-
Hi there,
I have problems understanding the data structure of SketchUp. Lets assume I have a empty scene and draw a simple rectangle. Then I can use ruby console like this
Sketchup.active_model.entities.at(4).vertices.at(1).position Point3d(0, 3.93701, 0)
Ok. Then I resize the rectangle using the scale tool (holding CTRL) by some factor and get
different valuesSketchup.active_model.entities.at(4).vertices.at(1).position Point3d(0.984252, 2.95276, 0)
Ok, undo the rescaling and put the rectangle to a group. Then the call is
Sketchup.active_model.entities.at(0).entities.at(1).vertices.at(0).position Point3d(0, 3.93701, 0)
Then I rescale as above, but this time the group. I again try
Sketchup.active_model.entities.at(0).entities.at(1).vertices.at(0).position Point3d(0, 3.93701, 0)
The thing is, that the position of the vertex has changed in the scene, but the output as above does not change. How can I get the "real" position instead?
kind regards,
curator -
Get the "container[s]" of the entities, get their "transformation[s]", then transform the vertex's point to match.
Then you'll have the point in the model coordinate system, not the point in the container's coordinates system...
This will give you the path through the nesting:
http://www.sketchup.com/intl/en/developer/docs/ourdoc/model#active_path
See these methods to get the 'accumulated' transformations of each container:
http://www.sketchup.com/intl/en/developer/docs/ourdoc/transformation
Advertisement