You don’t give us much to go on…
Assuming that all of the array of ‘faces
’ are within the ‘model.active_entities
’ context, AND that you will make the group in that same context too…
face_group = model.active_entities.add_group(faces)
The listed faces and their edges not needed to support excluded faces will be moved into the group.
You can always ‘move’ it into another context later with:
moved_group = some_other_entities.add_instance(face_group.entities.parent, face_group.transformation)
face_group.erase!
You cannot make a group of existing faces that are in a context other than the model.active_entities
, even if you keep the same context for the group, this cross-threading will usually make a BugSplat!
If you want to do this you need to copy the faces into the new group [initially created empty] with:
copy_group = some_entities_context.add_group()
Then iterate the faces
and replicate the them one at a time inside the copy_group.entities
using:
new_face = copy_group.entities.add_face(face_outer_loop.vertices)
BUT if you know the face will have some holes [if face.loops[1] ...
], then you need to collect the vertices of the inner holes, make those temporary faces and then make the other loop face, erasing the inner unwanted ones afterwards…
outer_loop = face.outer_loop
inner_loops = face.loops - [outer_loop]
holes = []
inner_loops.each{|loop|
holes << copy_group.entities.add_face(loop.vertices)
}
copy_group.entities.add_face(outer_loop.vertices)
copy_group.entities.erase_entities(holes) if holes[0]
This is repeated for each face.
If you want to ‘move’ rather than ‘copy’ the faces, you need to iterate them and collect their edges [making sure to NOT include any edges which support a face not inside ‘faces’], then erase the faces and those edges…