Python equivalent of gh "isPlanar"


(Declan Halpin) #1

Hi,

Is there a way in python to test if a srf is planar? I’m thinking of the isPlanar component in gh, but can’t find anything in python.

tx,

dh


(IVELIN PEYCHEV) #2

the float you put in is the tolerance.


(Declan Halpin) #3

Thank you!


(Chris Hanley) #4

fyi, you can also search the rhinocommon api. (you mentioned you “couldn’t find anything python”, but I’m not sure what that meant.)

https://developer.rhino3d.com/api/RhinoCommon/html/Overload_Rhino_Geometry_Curve_IsPlanar.htm


(Declan Halpin) #5

Ivelin,

I am getting an error when I run .IsPlanar on a srf. Can you see what I’m doing wrong?

tx,

dh


(IVELIN PEYCHEV) #6

You have to convert the guid into an object. Perhaps you haven’t set the type in the input.

Right-click the “X” input go to the bottom of the context menu and select that the type should be surface.


(Declan Halpin) #7

oh, right, of course… Thanks!


#8

In rhinoscriptsyntax it’s

rs.IsSurfacePlanar(srfID,tolerance) 
#tolerance argument optional, defaults to file abs. tolerance

(Tom) #9

As a kind of a bonus:
You can also easily implement this functionality completely for yourself. Its a great practice on programming in Rhino.

A surface is planar if all controlpoints are in a plane. You can check for a point in plane, by for instance picking 3 points create a plane and change basis it to the world plane and evaluating z.
Another way, and even more shorter: A surface is planar if the distance between the controlpoint and its corresponding greville point is zero. At least if its not an uncurved kinked surface. Which is extremely unlikely bytheway…