Crop boxes for views (C#)

#1 should be this property: Revit API 2026 Documentation

#3 should be this property: Revit API 2026 Documentation

#2 might be the actual curves from the cropped view you can use this method: Revit API 2026 Documentation. Note that the coordinates of such will eventually be returned relative to the view’s frame not model space.

If you’re having trouble with one or the other, post a code snippet and we can help narrow it down. Otherwise we’re just passing links and giving things arbitrary numbers. :slight_smile:

1 Like

it starts from the view’s cropbox. if i understand u correctly, u need its geometries in sheet space. either like what i did in rvt 2016 by cheesing with scale property (for lack of better words) or even better to set up a matrix chain with those two trans properties then apply it onto the geometries. they both worked fine as i tested last time.

about crop or annotation crop. i feel like ViewCropRegionShapeManager Class would help. GetCropShape() or GetAnnotationCropShape() and add a bit of curve re-ordering in model space to get a specific curve if u want to.

this even comes with boundaries. (but the doc mentioned crop splitting, so beware of that.)
Revit API 2026 Documentation

            //get view crop size of master
            View viewx = doc.GetElement(masterViewport.ViewId) as View;
            BoundingBoxXYZ cropBox = viewx.CropBox;

            XYZ cropMin = cropBox.Min;
            XYZ cropMax = cropBox.Max;
            XYZ cropCentre = (cropMin + cropMax) * 0.5;

            double width = cropBox.Max.X - cropBox.Min.X;
            double height = cropBox.Max.Y - cropBox.Min.Y;
            double widthSheet = width * 6.095; // Need to take into account the scale of the sheet.
            double heightSheet = height * 6.095; // Need to take into account the scale of the sheet.

            // Get viewport alignment points
            View sheetView = doc.GetElement(masterViewport.SheetId) as View;
            Outline masterOutline = masterViewport.GetBoxOutline();

            if (masterOutline == null)
            {
                TaskDialog.Show("Error", "Viewport alignment points can't be found.");
                return Result.Failed;
            }

            XYZ min = masterOutline.MinimumPoint;
            XYZ max = masterOutline.MaximumPoint;

            // Define alignment points  *** But these are the viewport... not the crop and nothing I seem to change makes a difference. *** 
            XYZ topLeft = new XYZ(min.X, max.Y, 0);
            XYZ topRight = new XYZ(max.X, max.Y, 0);
            XYZ bottomLeft = new XYZ(min.X, min.Y, 0);
            XYZ bottomRight = new XYZ(max.X, min.Y, 0);
            XYZ centre = masterViewport.GetBoxCenter();
1 Like

I can’t confirm (faster to test in Python), but I think you need to take the transform of the crop box into account.

Tried that too… and it seems to work for some views but not others…
It’s going back on the shelf. :person_facepalming:

What is the intent with the crop box? Asked another way, once you have this info correctly gathered what do you want to do with it?

Some (perhaps all) of the typical uses are better found by another means.

I thought it’d be, er… fun… to pick a master view and then a point of its crop box and then align other views to the same point.

So bottom left to bottom left…

I did it with scope boxes first and didn’t think this would be difficult. :zany_face:

1 Like

Is the goal to align the view, or to align the model elements?

It’s a subtle yet meaningful difference.

In the first the intersection of column A1 will ensure that you can ‘flip though’ and see how elements align vertically even when the crops don’t align.

In the second you can pack views on the sheet in a consistent way so you know where to start scanning for data.

crop box of views…
top left point to top left point for example… Crop boxes that do not share scope boxes.

1 Like

I will add that what you are trying to do may be redundant because of the new view alignment system that got implemented in Revit 2026. Help | View to Sheet Positioning & Automated Placement | Autodesk

So it might be wise to get some what there, allow others to be done manually for now and move to this new system?

Just have a thought on if its wise to push more development time into it when there is a possible OOTB solution

4 Likes