I want a script that creates a clipping plane on a selected surface, with depth = 0 and with the clipping plane graphic location centred on the centroid of the chosen planar surface. However, the clipping plane graphic that is created gets placed in a seemingly random, but consistent, location for each surface selected
As I have some python knowledge, but I’m completely new Rhino scripting, I thought it would be fun and a learning experience to ask ChatGPT 4 for the script. Script and testing geometry attached.
From inspection of the run time variables clipping_plane.ClippingPlaneGeometry.Plane value is in exactly the right spot, but the display/glyph is somewhere else. I’ve inspected manually created sections (Drafting → Sections → Create), and this property matches the glyph location, so I’m confused as why it isn’t the same when creating them when using AddClippingPlane().
As an aside, is there a scripting tool which allows you to inspect the RhinoCommon calls that are happening in the background when you are running built-in Rhino commands? E.g. creating sections.
With Rhino.FileIO.File3dmObjectTable.AddClippingPlane(Plane plane, Double uMagnitude, Double vMagnitude, Guid clippedViewportId), the clipping plane will be contained in a rectangle that starts at the origin of the given plane, and extends by the given magnitude in the x and y axis directions of the plane. In other words, the origin of plane is the bottom left corner of the clipping plane.
To get the center of the clipping plane at the center of the selected surface in your script, move the origin of the plane to the bottom left corner that you want for the clipping plane:
Thank you very much Pierre! The example makes this clear and to be honest I was trying to find examples but didn’t notice the “Example” button which is a bit hidden in the default ‘Dark Mode’, or at least with my poor eyesight. Thank you again.