usingSystem;partialclassExamples{publicstaticRhino.Commands.ResultAddClippingPlane(Rhino.RhinoDoc doc){// Define the corners of the clipping planeRhino.Geometry.Point3d[] corners;Rhino.Commands.Result rc =Rhino.Input.RhinoGet.GetRectangle(out corners);if(rc !=Rhino.Commands.Result.Success)return rc;// Get the active viewRhino.Display.RhinoView view = doc.Views.ActiveView;if(view ==null)returnRhino.Commands.Result.Failure;Rhino.Geometry.Point3d p0 = corners[0];Rhino.Geometry.Point3d p1 = corners[1];Rhino.Geometry.Point3d p3 = corners[3];// Create a plane from the corner pointsRhino.Geometry.Plane plane =newRhino.Geometry.Plane(p0, p1, p3);// Add a clipping plane object to the documentGuid id = doc.Objects.AddClippingPlane(plane, p0.DistanceTo(p1), p0.DistanceTo(p3), view.ActiveViewportID);if(id !=Guid.Empty){
doc.Views.Redraw();returnRhino.Commands.Result.Success;}returnRhino.Commands.Result.Failure;}}
importRhinoimport scriptcontext
importSystem.GuiddefAddClippingPlane():# Define the corners of the clipping plane
rc, corners =Rhino.Input.RhinoGet.GetRectangle()if rc!=Rhino.Commands.Result.Success:return rc
# Get the active view
view = scriptcontext.doc.Views.ActiveViewif view isNone:returnRhino.Commands.Result.Failure
p0, p1, p2, p3 = corners
# Create a plane from the corner points
plane =Rhino.Geometry.Plane(p0, p1, p3)# Add a clipping plane object to the document
id = scriptcontext.doc.Objects.AddClippingPlane(plane, p0.DistanceTo(p1), p0.DistanceTo(p3), view.ActiveViewportID)if id!=System.Guid.Empty:
scriptcontext.doc.Views.Redraw()returnRhino.Commands.Result.SuccessreturnRhino.Commands.Result.Failureif __name__=="__main__":AddClippingPlane()
PartialClassExamplesPublicSharedFunctionAddClippingPlane(ByVal doc AsRhino.RhinoDoc)AsRhino.Commands.Result' Define the corners of the clipping planeDim corners AsRhino.Geometry.Point3d()=NothingDim rc AsRhino.Commands.Result=Rhino.Input.RhinoGet.GetRectangle(corners)If rc <>Rhino.Commands.Result.SuccessThenReturn rc
EndIf' Get the active viewDim view AsRhino.Display.RhinoView= doc.Views.ActiveViewIf view IsNothingThenReturnRhino.Commands.Result.FailureEndIfDim p0 AsRhino.Geometry.Point3d=corners(0)Dim p1 AsRhino.Geometry.Point3d=corners(1)Dim p3 AsRhino.Geometry.Point3d=corners(3)' Create a plane from the corner pointsDim plane AsNewRhino.Geometry.Plane(p0, p1, p3)' Add a clipping plane object to the documentDim id AsGuid= doc.Objects.AddClippingPlane(plane, p0.DistanceTo(p1), p0.DistanceTo(p3), view.ActiveViewportID)If id <>Guid.EmptyThen
doc.Views.Redraw()ReturnRhino.Commands.Result.SuccessEndIfReturnRhino.Commands.Result.FailureEndFunctionEndClass