MeshEval error "AddMessageForWarnings"

Hi,

I have this function in grasshopper/python.

import rhinoscriptsyntax as rs
import ghpythonlib.components as ghcomp

for crv in curves:
    #pts = rs.CurveEditPoints(crv)
    pts = ghcomp.ControlPoints(crv)[0]
    for pt in pts:
        param = ghcomp.MeshClosestPoint(pt,mesh_o)[2]
        pt_on_flat = ghcomp.MeshEval(mesh_f,param)

The error I get is this:
AttributeError: ‘Python3Component’ object has no attribute ‘AddMessageForWarnings’

param_on_org gives an ok result like:
0[0.000;0.500;0.500;0.000]

“mesh_o” and “mesh_f” is declared as meshes on the component
“curves” are declared as curves on the component.

Help Please
Best regards
meshEval.gh (62.5 KB)

Isn’t there anyone who have had this issue before?

I don’t use ghpythonlib.components like this, so I’ve not seen this error until now:

Traceback (most recent call last):
  File "rhinocode:///grasshopper/1/65905af3-8a55-4e39-9243-db9a35ddcd28/f045cc49-f925-4319-b898-0b3612458f2b", line 9, in <module>
  File "...\.rhinocode\py39-rh8\site-rhinoghpython\ghpythonlib\components.py", line 171, in component_function
    do_this = sc.doc.Component.AddMessageForWarnings
AttributeError: 'Python3Component' object has no attribute 'AddMessageForWarnings'

Similar error in an IronPython 2 component. But despite the warnings, does it work in a GHPython one?:

meshEval_GHPython.gh (71.7 KB)

If you need to create GH_Python components:
make_GH_Python_component.gh (7.4 KB)

Hi,

No it doesn’t seam to continue despite the warning.

I’d rather not use ghcomp eighter, but cant find a rhino/rhinoscriptsyntax that does the same job as this component.

Rhinoscriptsyntax don’t seam to have Parameter as result of meshClosestPoint.

If someone can rewrite it to work I would be forever happy

Have you tried placing and connecting the actual Grasshopper components? It’s often faster as it skips the Python automagick, Pythonnet and then Python, and then going all the way back again.

Node in Code looked amazing, but unfortunately I had problems too (just with the colour Gradient component), and never persisted with it.

Yes, that was my first solution.
But it is placed in a very long chain of commands and will handle around 40-100 meshes at a time.
some meshes have many curves, some have none.
And this made it hard to keep the curves to the correct meshes even if they are grafted.

Thats why I thought of creating the points and move them to the other mesh in one component instead even if it might even take more time to calculate.

Here’s using RhinoCommon directly (in GHPython):


240528_MeshEval_GHPython_00.gh (7.3 KB)

This will likely work with the new script editor as well. At least using IronPython.

1 Like

This was a regression in 8.8 RC. I have put a fix for it in the next build (most probably today)

Thanks!

1 Like