Triangulate a mesh via RhinoCommon

Hi,

I’m not seeing a means to triangulate a mesh via RhinoCommon.
Am I missing something or should I stick with scripting the _TriangulateMesh command ?

I found the answer:
http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Collections_MeshFaceList_ConvertQuadsToTriangles.htm

Thanks
-Willem

Not sure if it is the same code, but a MeshFaceList has the ConvertQuadsToTriangles method.

2 Likes

Hi Luis,

Yes, I just found the answer myself and edited the question. Thanks

oops, too fast for me!

Hi @Willem, I have a question to this somewhat old thread.

Faces.ConvertQuadsToTriangles that you suggest returns a bool. How do I get the actual triangluated mesh?

thanks,
david

Hi @DavAndLar,

ConvertQuadsToTriangles modifies the mesh in-place.

import Rhino
import scriptcontext as sc

def test_meshbox():
    interval = Rhino.Geometry.Interval(0, 10)
    plane = Rhino.Geometry.Plane.WorldXY
    box = Rhino.Geometry.Box(plane, interval, interval, interval)
    mesh = Rhino.Geometry.Mesh.CreateFromBox(box, 1, 1, 1)
    # just triangles
    mesh.Faces.ConvertQuadsToTriangles()
    sc.doc.Objects.AddMesh(mesh)
    sc.doc.Views.Redraw()

if __name__=="__main__":
    test_meshbox()

– Dale