Wish: rs.MeshObjects()


As the title says… Thx, --Mitch

(Rajaa Issa) #2

tagging @dale to take note of it.


We need rhinoscript “MeshingParameters” function too.
Small example of MeshObjects with no user interface and render mesh parameters:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def MeshObjects(_ids):
    objs = [sc.doc.Objects.Find(id) for id in _ids]
    mp = Rhino.Geometry.MeshingParameters()
    mesh_ids = []
    for obj in objs:
        if isinstance(obj.Geometry, Rhino.Geometry.Brep):
            brep = obj.Geometry
        elif isinstance(obj.Geometry, Rhino.Geometry.Extrusion):
            brep = obj.Geometry.ToBrep(True)
        elif isinstance(obj.Geometry, Rhino.Geometry.Surface):
            brep = Rhino.Geometry.Brep.CreateFromSurface(obj.Geometry)
        mesh = Rhino.Geometry.Mesh.CreateFromBrep(brep,mp)[0]
        m_id = sc.doc.Objects.AddMesh(mesh)

    if len(mesh_ids)==0: return
    sc.doc.Views.RedrawEnabled = True
    return mesh_ids