Get points from a Sketchup object
-
Is there a method in ruby or a way to get all the 3D points (x,y,z) from a sketchup Object?
Thanks in advance.
-
Moved this to the Developers' Forum where it will get better attention...
https://developers.google.com/sketchup/docs/ourdoc/boundingbox
returns info like center and the eight corners of the object's bounds.https://developers.google.com/sketchup/docs/ourdoc/transformation
returns info like 'origin', rotation etc.If you want the 'vertices' [end-points] of all edges in an object you iterate the edges, collect an array of the edge.vertices, .flatten! it, .uniq! it and then iterate the vertices, collecting all of the vertex.position point3d info which is xyz - however if it's an instance or group you need to apply its transformation to these to get them in 'model-coordinates' if needed...
-
An object of what you mean is a Sketchup Drawingelement.
If the Drawingelement is a Face, Edge, ArcCurve or Curve, it will have a method to get all vertices, and for each vertex you can get the position (which is what you want):
positions = face.vertices.map{|v| v.position}
If the Drawingelement is a Group, ComponentInstance of Image, it is "a model" in the model any you have to loop over the contained entities:
group.parent.entities.find_all{|e| e.respond_to?(:vertices) }. map{|e| e.vertices.map{|v| v.position} }.flatten
or with
component.definition.entities
Advertisement