Agnel Kurian Agnel Kurian - 4 months ago 13
Ruby Question

Quickest Way to create Face and Edge objects in Sketchup

I have to render a mesh of a few thousand polygons in Google Sketchup. I find that

add_face
tends to get slower as the number of faces in the model increases. I believe this to be due to some edge detection algorithm that Sketchup is running behind the scenes. Hopefully, there should be some way to suppress this edge detection or other processing that Sketchup is doing till all faces have been added to the model.

I found
add_faces_from_mesh
and
fill_from_mesh
to be much faster but I end up with a mesh consisting of
Surface
instances instead of the
Face
and
Edge
objects I am looking for.

So, what is the fastest way to generate a model consisting of
Face
and
Edge
objects in Sketchup? Is there a way to generate
Edge
and
Face
objects from a
Surface
object?

Update: I just read here that using
Model::start_transaction
and
Model::commit_transaction
can be used to speed things up but I found that the improvements are not very significant. Anything else I can do?

Answer

I found add_faces_from_mesh and fill_from_mesh to be much faster but I end up with a mesh consisting of Surface instances instead of the Face and Edge objects I am looking for.

Calling add_faces_from_mesh or fill_from_mesh with the smooth_flags parameter explicitly set to zero correctly constructs Face and Edge objects. Sketchup Documentation claims that smooth_flags defaults to zero... my trials show otherwise.