Add_faces_from_mesh returns what ?
-
Hi guys,
As the API doc says, 'add_faces_from_mesh' is supposed to return an array of newly created faces, if successful.
I always got 0 or nil as return values (like 'fill_from_mesh').
If I want to retrieve the newly created faces, do I have to store the number of entities before an 'add_faces_from_mesh', then count the new entities.length after the 'add_faces_from_mesh' call, then iterate through these new entities to retrieve the faces ???
Any help appreciated -
Yea, the docs are wrong.
To get the new entities:
entities = Sketchup.active_model.active_entities cache = entities.to_a entities.add_faces_from_mesh( mesh ) new_entities = entities.to_a - cache
-
Thanks ThomThom,
Here is what I planned to do:nEntsBefore=Sketchup.active_model.entities.length Sketchup.active_model.entities.add_faces_from_mesh(m) nEntsAfter=Sketchup.active_model.entities.length arrayOfNewFaces=[] nEntsBefore.upto(nEntsAfter-1) { |i| next if ent=Sketchup.active_model.entities[i]; arrayOfNewFaces.push(ent) }
Your code is mush more simple than mine
Advertisement