Why does Rhino.Geometry.Plane.Flip() return NoneType?

import Rhino
import scriptcontext
import System.Guid

def AddClippingPlane():
    # Define the corners of the clipping plane
    rc, corners = Rhino.Input.RhinoGet.GetRectangle()
    if rc!=Rhino.Commands.Result.Success: return rc

    # Get the active view
    view = scriptcontext.doc.Views.ActiveView
    if view is None: return Rhino.Commands.Result.Failure

    p0, p1, p2, p3 = corners
    # Create a plane from the corner points
    plane = Rhino.Geometry.Plane(p0, p1, p3)
    plane = plane.Flip()
    # Add a clipping plane object to the document
    id = scriptcontext.doc.Objects.AddClippingPlane(plane, p0.DistanceTo(p1), p0.DistanceTo(p3), view.ActiveViewportID)
    if id!=System.Guid.Empty:
        scriptcontext.doc.Views.Redraw()
        return Rhino.Commands.Result.Success
    return Rhino.Commands.Result.Failure

if __name__=="__main__":
    AddClippingPlane()

you don’t need to write plane = plane.Flip(). It should just be

plane.Flip()

I know that I wanna replace whatever is in the ‘plane’ variable with the flipped one.

that’s what just writing plane.Flip() does. It actually flips that plane. No need for replacement. That method changes the actual item it acts on, like a transform.

Thanks Michael.

That seems so un-python. :smiley:

Not really, many standard Python objects have functions that change data “in place”, such as list.reverse() or list.sort().

Thanks @AndersDeleuran

I’m just used to variable = variable.transformation()

1 Like

Something else to watchout for in Python is that it passes pointers to procedures for objects. Say for instance you include the name of a 3D point object in the calling list of a procedure and then modify the X property of the point: pt.X = 12.7 inside the procedure.
You will find that back in the calling program the X property of the point is also changed to 12.7. This can simplify the return statement in the procedure since there is no need to include any object that was passed by pointer and had some of its properties modified. Its changed values will already be “passed” back to the calling program via its pointer. You can really get burned troubleshooting your code if you forget this.

Regards,
Terry.

Thanks for sharing Terry,

It’s a bit hardcore terminology so I didn’t really understand but I’ll keep in mind to look this up if I can’t figure out why things are not working.