Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Trimming a mesh in Python-Rhinocommon

$
0
0

@Goodriver wrote:

I am trying to create a script in python-Rhinocommon that trims an existing mesh. It seems to work for a small mesh, but when applying it to a large one it seems to trim more faces than necessary. I've nicked part of the code about topology vertices from another script, but I do not fully understand yet how it works.test_grids.3dm (112.9 KB)

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext
import rhinoscript.utility as rhutil

me=rs.GetObject("Select a mesh to trim ")
mesh = rhutil.coercemesh(me, True)

go=Rhino.Input.Custom.GetObject()
go.GeometryFilter=Rhino.DocObjects.ObjectType.MeshVertex
go.SetCommandPrompt("Get mesh vertex")
go.GetMultiple(0,1000)
objrefs = go.Objects()
topology_indices=[item.GeometryComponentIndex.Index for item in objrefs]
points = []
for index in topology_indices:
    vertex_indices = mesh.TopologyVertices.MeshVertexIndices(index)
    points.append(vertex_indices[0])

points = sorted(points)
for pt in reversed(points):
    print pt
    test = mesh.Vertices.Remove(pt,True)

scriptcontext.doc.Objects.Replace(me,mesh)
mesh.Dispose()

scriptcontext.doc.Views.Redraw()

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles