Yes I have also duplicated meshes by separately copying the faces and vertices with good results. But it takes more coding. And may be slower to execute.
There is RhinoScript code that will do the same thing as the RhinoCommon code I showed.
Yes I have also duplicated meshes by separately copying the faces and vertices with good results. But it takes more coding. And may be slower to execute.
There is RhinoScript code that will do the same thing as the RhinoCommon code I showed.
Your mileage may vary depending upon what you want to do with the mesh. If you want to see the modified mesh then you of course have to replace the geometry attached to the displayed ID. But if you want the geometey itself then using SetVertex method could be quick and simple. I do a lot of these geometry-only type of operations with meshes that are large (20M faces) and so need to be efficient in order to avoid hour-long execution times that some methods take (try doing .Contains on the whole mesh to check which points are inside and outside of a closed curve - you will regret it especially when this can be done in under 30 sec with more contemplative code).
To be more precise, I have modified my first post to say:
you can directly modify a vertex in the geometry of a mesh.
Hi
I got some newbie questions how can I get the id of mesh???
is there any example code that can only use python in grasshopper??
If the mesh is displayed in Rhino, you could use a Python script like this:
import rhinoscriptsyntax as rs
def getGeo(id): return doc.Objects.Find(id).Geometry
# To get meshes displayed in Rhino you can use this:
meshes = rs.ObjectsByType(32)
# To get the first mesh on the list use this:
mesh = meshes[0]
# To see the type and ID of mesh use this:
print type(mesh), 'ID = ', mesh
# To get the geometry of the mesh use this:
meshGeo = getGeo(mesh)
# To get the vertices of the mesh do this:
vertices = meshGeo.Vertices
# To see the XYZ values of the first vertex do this:
vertex0= vertices[0]
print vertex0.X , vertex0.Y , vertex0.Z
# To get the number vertices in the mesh do this:
vcount = vertices.Count
print vcount
For a mesh I have, The above gives:
<type ‘Guid’> ID = c63b699d-b2ec-48d2-9421-761c92c2bb96
227.883 507.707 93.0731
1023945
Does this help?
Regards,
Terry.
Thank you so much for the informative python example!