partialclassExamples{publicstaticRhino.Commands.ResultCurveBoundingBox(Rhino.RhinoDoc doc){// Select a curve objectRhino.DocObjects.ObjRef rhObject;var rc =Rhino.Input.RhinoGet.GetOneObject("Select curve",false,Rhino.DocObjects.ObjectType.Curve,out rhObject);if(rc !=Rhino.Commands.Result.Success)return rc;// Validate selectionvar curve = rhObject.Curve();if(curve ==null)returnRhino.Commands.Result.Failure;// Get the active view's construction planevar view = doc.Views.ActiveView;if(view ==null)returnRhino.Commands.Result.Failure;var plane = view.ActiveViewport.ConstructionPlane();// Compute the tight bounding box of the curve in world coordinatesvar bbox = curve.GetBoundingBox(true);if(!bbox.IsValid)returnRhino.Commands.Result.Failure;// Print the min and max box coordinates in world coordinatesRhino.RhinoApp.WriteLine("World min: {0}", bbox.Min);Rhino.RhinoApp.WriteLine("World max: {0}", bbox.Max);// Compute the tight bounding box of the curve based on the // active view's construction plane
bbox = curve.GetBoundingBox(plane);// Print the min and max box coordinates in cplane coordinatesRhino.RhinoApp.WriteLine("CPlane min: {0}", bbox.Min);Rhino.RhinoApp.WriteLine("CPlane max: {0}", bbox.Max);returnRhino.Commands.Result.Success;}}
importRhinoimport scriptcontext
defCurveBoundingBox():# Select a curve object
rc, rhobject =Rhino.Input.RhinoGet.GetOneObject("Select curve",False,Rhino.DocObjects.ObjectType.Curve)if rc!=Rhino.Commands.Result.Success:return# Validate selection
curve = rhobject.Curve()ifnot curve:return## Get the active view's construction plane
view = scriptcontext.doc.Views.ActiveViewifnot view:return
plane = view.ActiveViewport.ConstructionPlane()# Compute the tight bounding box of the curve in world coordinates
bbox = curve.GetBoundingBox(True)ifnot bbox.IsValid:return# Print the min and max box coordinates in world coordinates
print "World min:", bbox.Min
print "World max:", bbox.Max# Compute the tight bounding box of the curve based on the # active view's construction plane
bbox = curve.GetBoundingBox(plane)# Print the min and max box coordinates in cplane coordinates
print "CPlane min:", bbox.Min
print "CPlane max:", bbox.Maxif __name__=="__main__":CurveBoundingBox()
PartialClassExamplesPublicSharedFunctionCurveBoundingBox(doc AsRhino.RhinoDoc)AsRhino.Commands.Result' Select a curve objectDim rhObject AsRhino.DocObjects.ObjRef=NothingDim rc =Rhino.Input.RhinoGet.GetOneObject("Select curve",False,Rhino.DocObjects.ObjectType.Curve, rhObject)If rc <>Rhino.Commands.Result.SuccessThenReturn rc
EndIf' Validate selectionDim curve = rhObject.Curve()If curve IsNothingThenReturnRhino.Commands.Result.FailureEndIf' Get the active view's construction planeDim view = doc.Views.ActiveViewIf view IsNothingThenReturnRhino.Commands.Result.FailureEndIfDim plane = view.ActiveViewport.ConstructionPlane()' Compute the tight bounding box of the curve in world coordinatesDim bbox = curve.GetBoundingBox(True)IfNot bbox.IsValidThenReturnRhino.Commands.Result.FailureEndIf' Print the min and max box coordinates in world coordinatesRhino.RhinoApp.WriteLine("World min: {0}", bbox.Min)Rhino.RhinoApp.WriteLine("World max: {0}", bbox.Max)' Compute the tight bounding box of the curve based on the ' active view's construction plane
bbox = curve.GetBoundingBox(plane)' Print the min and max box coordinates in cplane coordinatesRhino.RhinoApp.WriteLine("CPlane min: {0}", bbox.Min)Rhino.RhinoApp.WriteLine("CPlane max: {0}", bbox.Max)ReturnRhino.Commands.Result.SuccessEndFunctionEndClass