How to replicate EnableClippingPlane command in a script?

I can’t figure out how EnableClippingPlane and DisableClipping can be access from rhinoscript or RhinoCommon. I’ve see that there has been a new method provided in Rhino 6, but without an example I couldn’t figure out how it was meant to be used.

I found also this example here, but I’m not sure if this is meant to work “globally” or only in a specific view like EnableClippingPlane and DisableClipping:

Rhino.DocObjects.ObjRef obj = new Rhino.DocObjects.ObjRef(id);
Rhino.DocObjects.ClippingPlaneObject cpObj = obj.Object() as Rhino.DocObjects.ClippingPlaneObject;

There have been a similar question asked in 2014, but I’m hoping that since then something new might have emerged.

If there is any simpler method available please let me know.

got it :slight_smile:

Sorry for the crappy screenshot, will edit it properly tomorrow, but what I think confused me was that clipping planes store the viewport Ids, rather than viewport Ids “having” clipping planes.

To disable clipping plane corresponding RemoveClipViewport methods works.

Hi @Daniel_Krajnik,

The EnableClippingPlane and DisableClippingPlane commands work by adding or removing viewport ids to clipping plane objects that exists in the document. Looking at ClippingPlane.ViewIds is a good place to start.

– Dale

1 Like

Thanks, reading through the previous threads I realize that you needed to repeat that a few times to many people, so I very much appreciate you patience.

I couldn’t however see the viewId property on the clipping plane objects. I did see you mention it, but it doesn’t appear anywhere as reported at least by the IronPython debugger:

Really sorry, about the screenshot quality :disappointed:

As mentioned above though Add/RemoveClipViewport methods does work (for me)

Hmm the ViewIds property that you mentioned belongs to a Rhino.Render.ChangeQueue.ClippingPlane class, while I was looking at ClippingPlaneObjects in the active Rhino doc. Sorry, I’m sure that’s a very basic question, but how one binds the two together. I can’t seem to find viewIds on the clipping planes.

From your ClippingPlaneObject get its geometry, which will give you ClippingPlaneSurface from the namespace Rhino.Geometry. This geometry will have ClippingPlaneSurface.ViewportIds Method (and the add and remove ID methods)

The other one is indeed for ChangeQueue implementations in realtime render engine integrations.

1 Like

Perfect, thank you very much. I expected it to be a property, methods don’t get displayed in the PythonEditor debugger (unless they are in is some “dunder” now that I thought about it…). Very helpful!