How to set the viewport to only display areas in a defined boundingbox?

I don’t want to change the size of the viewport, but want to clip the display area with a boundingbox, that is to display
the objects or part of objects in a boundingbox area only.
So I try ActiveViewport.SetClippingPlanes(box.BoundingBox) method, but it doesn’t work.
Can someone help me achieve this effect?

	protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
	{
		Rhino.Geometry.Box box;
		Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetBox(out box);
		if (rc != Rhino.Commands.Result.Success)
			return rc;

		Rhino.Display.RhinoView view = doc.Views.ActiveView;
		view.ActiveViewport.SetClippingPlanes(box.BoundingBox);
		doc.Views.Redraw();

		return Rhino.Commands.Result.Success;
	}

I guess you’re looking for ZoomBoundingBox method:

protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
{
  Box box;
  var rc = Rhino.Input.RhinoGet.GetBox(out box);
  if (rc != Rhino.Commands.Result.Success)
    return rc;
  var view = doc.Views.ActiveView;
  view.ActiveViewport.ZoomBoundingBox(box.BoundingBox);
  doc.Views.Redraw();
  return Rhino.Commands.Result.Success;
}
1 Like

Oh no, what I think is that the object inside the box is displayed, the object outside it is not displayed, and the cross-border object displays the part inside the box。

Hi @chen_manhong,

This is actually pretty easy to to using a display conduit. Here is a sample you can use as a starting point.

SampleCsViewBoundingBox.cs

– Dale