Message 1 of 7

Not applicable
07-14-2013
06:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to resize the Cropbox of the active view using the API for plans and sections using Revit 2013 . (This code was tested on Plan views).
The code below asks the user for a PickBox which is then applied as the Min and Max values of the Cropbox.
The cropbox appears to be created, but doesn't match the dimensions given (it just crops to the Revit default extents).
Does anyone have any suggestions for how to programmatically change the size of a 2D view cropbox? (I've seen the 3D tutorial here: http://thebuildingcoder.typepad.com/blog/2009/12/crop-3d-view-to-room.html, but I'm looking for how to crop 2D views)
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)] public class TestButton2 : IExternalCommand { public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Autodesk.Revit.DB.View myNewCroppedView = commandData.Application.ActiveUIDocument.ActiveView; Autodesk.Revit.DB.ViewPlan myPlanView = myNewCroppedView as ViewPlan; Autodesk.Revit.UI.Selection.PickedBox myBox = commandData.Application.ActiveUIDocument.Selection.PickBox(Autodesk.Revit.UI.Selection.PickBoxStyle.Crossing); XYZ pt1 = myBox.Max; XYZ pt2 = myBox.Min; XYZ pt2WithNewZ = new XYZ(pt2.X, pt2.Y, -100); myNewCroppedView.CropBox.Max = pt1; myNewCroppedView.CropBox.Min = pt2WithNewZ; myNewCroppedView.CropBox.Enabled = true; myNewCroppedView.CropBoxActive = true; return Result.Succeeded; } }
Solved! Go to Solution.