Grasshopper control clipping plane with plane input

Hello does anyone know about some C# or python script which allows to control a clipping plane with a plane. I know about referencing clipping planes as guides and have found some older C# scripts which should work but arent for me. got a error message which poped up infinitly so I had to say show no more which is why i cant post it here (forgot to copy). but as far as i remember it said something about a part of the script being outdated

this is the code

var cp = new Rhino.DocObjects.ObjRef(id);
var source = cp.ClippingPlaneSurface().Plane;
RhinoDoc.ActiveDoc.Objects.Transform(id, Transform.PlaneToPlane(source, pl), true);

forum link Reference a clipping plane in grasshopper

ideally the script should create the clipping plane first from the plane. would make referencing from rhino obsolete

any help would is appreciated (9.6 KB)

create your geometry and your clipping plane. in grasshopper, right click on guid and get the clipping plane

thank you for the quick help but sadly im missing python 3. is there any easy way to update to python 3 (10.5 KB)

sorry to bother but it still seems like the python compoent how can in install it.
or maybe its easier to just post the code

"""Grasshopper Script"""
import Rhino

cp = Rhino.DocObjects.ObjRef(x)
source = cp.ClippingPlaneSurface().Plane
    x, Rhino.Geometry.Transform.PlaneToPlane(source, y), True)

getting some error

Should dissapear when you connect the guid to x and plane to y

they are connected. the error disappeared after I referenced a new guid. But now there is a new error

Instead of RhinoDoc.ActiveDoc first import scriptcontext as sc, then you can do : sc.doc.Objects.Transform()-call.

At the top add

import RhinoDoc

thank you gives no error bu also nothing gets clipped now

gives me: Runtime error (ImportException): No module named RhinoDoc

Btw, what version of rhino are you on?

Rhino 7 SR36 2023-12-12

FWIW you are not making any changes to the plane you get from the clipping plane, like is done in this reply Reference a clipping plane in grasshopper - #5 by Mahdiyar .

And you need to make sure that the clipping plane is set to clip in the viewport you’re looking at:

for me it seems not to work. maybe i do not understand how it should work?

Ah right, of course you need access directly to ActiveDoc because Grasshopper.

This script works:

__author__ = "jesterking"

import Rhino

# create an ObjRef
_cp = Rhino.DocObjects.ObjRef(cp)
# get the Plane out from the clipping plane
_cppl = _cp.ClippingPlaneSurface().Plane
# now transform the clipping plane by passing its GUID
# and a new transform that is created from the clipping
# plane to the new plane

It works with this definition:

The model has a box and one clipping plane, the definition will allow you to move the clipping plane on the Y axis.

ClippingPlanePython.3dm (2.8 MB) (9.7 KB)

thanks alot works fantastic

Is there an easy way to dynamicaly create guides / clipping planes along with the input planes ?
Im thinking about iterative processes with different counts of clipping planes