GHPython Component Boolean Operation Inconsistency

Hello everyone,

I am trying to flip a surface which is imported into a surface component in GH. The flip component doesn’t work. I’m not sure why since it doesn’t produce any error messages. GHPython (67.2 KB)

I put this simple code into the GHPython component to achieve flipping the surface:

import rhinoscriptsyntax as rs

if x:

  • a = rs.FlipSurface(y, True)*
  • a = y*

This works when the x is set to False toggle. But when it is set to True it gives an error:
“Unable to convert Rhino.Geometry.NurbsSurface into Brep geometry.”

What do you think is wrong?

first of all the method call returns a boolean and not the Surface
consider this instead:

if x:
    a = y
    a = y

and to solve the issue, set your type hint to Brep rather than Surface, or even leave it at “no type hint”

Thank you for your reply.

I changed the code as you stated and also selected “Brep” from the hint menu and also selected “no hint” both of which didn’t change the result.

When Brep is selected from the hint menu the error message changes to “Unable to convert boolean to Brep”.
When no hint is selected the original error message is shown.

The flip component also doesn’t flip the surface even though no error messages are shown. Why does it do that?

You’re right. The whole rhinoscriptsyntax library is a bit finicky to me. Why don’t you try this after you set the type hint to Brep on y

if x:
    a = y
    a = y

Flip() turns out to be a method in RhinoCommon SDK for Brep

1 Like

That solved the issue. Thanks a lot…

So, what’s the real difference between “rs.FlipSurface(y,True)” and “y.Flip()”?

Why the former doesn’t work and the latter work??

So if I understand correctly, the whole rhinoscriptsyntax library is like a wrapper around RhinoCommon. I usually call RhinoCommon API directly. In an effort to simplify coding, rhinoscriptsyntax sometimes behave strangely, as it seems to me at least.

1 Like

Yes and you can use this script to peak inside the wrapper:

1 Like

Yeah, I understand what you mean. It seemed funny that the original code didn’t work, because when I use the same code from within the EditPythonScript command inside Rhino, it worked. But the same code inside a GHPython component in GH, didn’t work…

Thanks, it is very useful…

Nicely done!

Thanks both :sunglasses: