Hi all,
I am aiming to close a mesh which due to some previous surface modifications (added approximated patch by blending two separate objects) has a number of small gaps at both ends. A closed mesh is required for the subsequent conversion into a solid SubD geometry and modifications in Grasshopper.
MatchMeshEdge - seems like a request for future work/Beta releases
Could you please advise me on how I can replicate the existing manual _MatchMeshEdge Rhino command in Grasshopper 3D (avoiding to bake the geometry and scripting a customised command via the MacroEditor )
Any GhPython and c# scripting solutions are also welcome.
The gaps are very tiny and manually I am able to close the mesh surface using the following _MatchMeshEdge parameters:
*DistanceToAdjust=0.1
*RatchetMode=On
I have access to the most up-to-date Rhino v6 and Rhino Beta versions.
I look forward to receiving your help/advice.
Thank you,
Ilja
import rhinoscriptsyntax as rs
import Grasshopper
import Rhino
rhdoc = Rhino.RhinoDoc.ActiveDoc
rhdoc.Views.RedrawEnabled = False
rh_mesh = rhdoc.Objects.AddMesh(mesh)
current = rhdoc.Objects.Find(rh_mesh).RuntimeSerialNumber
# Select the mesh at the end of the command, when it is preselected the options are not available
rhdoc.Objects.UnselectAll()
command = """_MatchMeshEdge _DistanceToAdjust 0.1 _RatchetMode=_On _SelId {} _EnterEnd""".format(str(rh_mesh))
rs.Command(command)
new_obj = rhdoc.Objects.AllObjectsSince(current)
if len(new_obj) > 0:
mesh_out = new_obj[0].Geometry.Duplicate()
else:
mesh_out = None
for m in new_obj:
rhdoc.Objects.Purge(m)
rhdoc.Objects.Purge(current)
rhdoc.Views.RedrawEnabled = True
in a GHPython component, where mesh is a GH mesh input, and mesh_out the output when successful.
Technically this is equivalent to baking, running a macro, and deleting the temporary baked geometries, but it’s all automated so I guess it’s not really an issue. You could also parametrize the DistanceToAdjust parameter by adding an input to the GHPython component and feeding that to the command through .format().