LearnRevitAPI

💡Pro Tip: How to Easily Get CropBox to Rotate Views with Revit API

May 29, 2025
Rotate Views with API

I want to share a quick tip on how to rotate views using Revit API.
As you know, we need to grab a CropBox to rotate the view orientation. And if you tried it with Revit API then you realized that view.CropBox just gives you the BoundingBoxXYZ and not the actual CropBox Element...
In the past I used an overcomplicated workaround, but recently I tried a simpler approach and it worked like a charm.
Let me share how to rotate views with API.
#1 Get CropBox
When you create a View in Revit it also creates CropBoxes as separate objects. And it means that CropBox Id relates to View Id and it always has the same difference.
So, here is the trick:
Get Id of a view and then increment it by 2 to get ElementId of a CropBox. That's it.
e.g.
view.Id = 13642
cropbox.Id = 13642 + 2
Here is a simple code snippet to test:
💡P.S.
This works well for ViewPlan.
ViewSection might have different offset. I haven't tested, but someone mentioned it's view.Id -1 instead of +2.
#2 Rotate View
Now you have the CropBox element, now it's same as Revit UI, we just need to rotate it with the desired angle (in radians!)
For that we need to use ElementTransformUtils. RotateElement.

It needs 4 arguments:
Document
CropBox_id
Rotation Axis (vertical line)
Angle in Radians
Here is a code where I take the BoundingBox of a CropBox and calculate a Centroid. Then we need to create a simple line that will represent the axis.
After that we just use all arguments to rotate.
Here is the code:

P.S.
If rotation looks off:
Ensure angle is in Radians
Try rotating in opposite direction (negative angle).
Why not use View.CropBox?
Some people might try to use View.CropBox property, but you will instantly realize that it returns a BoundingBoxXYZ and not the actual CropBox Element.
So, you won't be able to use that to rotate your view.
But don't worry. When I tried to rotate view for the first time, that's exactly what I tried to do as well. And I learnt really quick that's not the way to do it.
But luckily, now you know how to do it 👻.
P.S.
I used this workflow in the new tutorial where I show you how to Automate Sales Plans in Revit.
Click here to watch. (This workflow is used at 54:40 timestamp
Join Newsletter
📩 You will be added to Revit API Newsletter
Join Us!
which is already read by 9500+ people!




