My own implementation of the grasshopper GHPython plugin gives me an error when I call it from RhinoCompute, but it works fine when I open it directly from grasshopper.
I just want to implement a function to merge an open mesh into a closed mesh, here is the code.
#coding=utf-8
"""
close opening mesh
Inputs:
mesh: opening mesh
Output:
mesh_out: closed mesh
"""
from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper, GhPython
import System
import Rhino
import rhinoscriptsyntax as rs
class MyComponent(component):
def RunScript(self, mesh):
print(mesh)
meshobj = rs.coercemesh(mesh)
if not meshobj:
mesh_out = None
else:
mcopy = meshobj.DuplicateMesh()
distance = 0.1
rachet = True
rc = mcopy.MatchEdges(distance, rachet)
if rc:
rs.Redraw()
mesh_out = mcopy
else:
mesh_out = None
return mesh_out
It works fine in grasshopper!
Calling it with RhinoCompute gives an error and does not return the mesh.
warning: Parameter failed to collect data: component "closeMeshC" (d925838e-124f-46b6-9ce4-8bfaef877258)
What’s the problem? What should I do?
Thanks.