Dear Friends,
Can anyone help me to put outer edges of a face in an array?
Thank you for your help in advance…
Dear Friends,
Can anyone help me to put outer edges of a face in an array?
Thank you for your help in advance…
Face.#outer_loop-instance_method
# Create a series of points that define a new face.
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [9, 0, 0]
pts[2] = [9, 9, 0]
pts[3] = [0, 9, 0]
# Add the face to the entities in the model
face = entities.add_face(pts)
o_loop = face.outer_loop
# This o_edges - an array of Edge objects:
o_edges = o_loop.edges
How can I change o_edges to simple three-element arrays?
o_points = o_edges.vertices.map(&:position)
o_xyz_arrays = points.map(&:to_a)
BUT … getting the vertices array from edges means there’ll be 2 copies of each vertex, and they may not be in correct “winding order”.
So you should get the vertices from the Sketchup::Loop object.
Ie …
o_points = o_loop.vertices.map(&:position)
o_xyz_arrays = o_points.map(&:to_a)
Why use XYZ arrays when you can use Geom::Point3d objects ?
They have nice methods to do good things, and you can get the individual coordinates via the x(), y() and z() methods.
Thank you so much for your help. Your codes works well and solved my problem. Unfortunately I am biginner in ruby and working with edges is difficult for me.