Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Removing viewport clipping via Grasshopper C# component

$
0
0

@savage wrote:

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.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles