Removing viewport clipping via Grasshopper C# component

I am trying to turn off all clipping in the active viewport via this Grasshopper C# component:

  private void RunScript(bool Run, object y, ref object A)
    // Only modify clipping when Run is enabled
    //if (!Run) return;

    // Find and clear any active clipping of current view
    var view = RhinoDoc.ActiveDoc.Views.ActiveView;
    var viewport = view.ActiveViewport;
    var viewid = view.ActiveViewportID;

    Rhino.DocObjects.RhinoObject[] planes = RhinoDoc.ActiveDoc.Objects.FindByObjectType(Rhino.DocObjects.ObjectType.ClipPlane);
    foreach (var plane in planes) {
      // RemoveClipViewport does nothing if plane not clipping given view
      var cplane = (Rhino.DocObjects.ClippingPlaneObject) plane;
      A = cplane.RemoveClipViewport(viewport, true);

    Rhino.DocObjects.ClippingPlaneObject[] planes = RhinoDoc.ActiveDoc.Objects.FindClippingPlanesForViewport(viewport);
    foreach (var plane in planes) {
      A = plane.RemoveClipViewport(viewport, true);
      //A = plane.ClippingPlaneGeometry.RemoveClipViewportId(viewid);
      //A = plane.CommitChanges();

Here, viewport is correctly referring to the active viewport (Perspective, Top, etc.), and planes correctly extracts the single clipping plane I have in the model. However, even though RemoveClipViewport returns true, my model remains clipped in the viewport. Any ideas what is going wrong or are there alternative methods for doing this?

Edit: I should mention the commented lines are other attempts at removing the clipping, none of which worked. The Run parameter check is commented out for debugging.

You are missing a view redraw.

I added view.Redraw(); at the end of RunScript, but it had no effect. Something else I am missing?

Hmm, with true for committing changes I’m not sure why it isn’t working. @dale, does the code look like it should work?

I have attached Rhino+Grasshopper files for a simple example. The loop over RhinoDoc.ActiveDoc.Objects.FindClippingPlanesForViewport(viewport) is correctly over all clipping planes active on the current viewport and RemoveClipViewport returns true for all.

CommitChanges returns false unless the ClippingPlaneGeometry.RemoveClipViewportId(viewid) line is also uncommented, but in that case the viewport still remains clipped after this script is run.

GrasshopperClippingExample.3dm (104.1 KB) (5.4 KB)

I’ve logged this issue.

– Dale

I see you have already made a fix – thanks! Is it likely to make the next service release?

It’ll be in 6SR13.

1 Like