Rotate crop views on sheet

Hi Everyone,
I just wonder if anyone come across this idea before, due to my work I have to keep rotate and line up views in sheet. is it anyway we can rotate selected view with Dynamo? The rotate on sheet of Revit is very poor command, I usually have activate every single views then select crop view visible then rotate it. Is there any node or routine to allow rotate selected views?
Thanks for reading


Hi Vo,

Once you place a view on a sheet, it becomes a viewport element. Those have a location property that we can access through the API. Here’s a little example, I decided to dust off my UI nodes for it:

Here’s the code. Once you ignore the default inputs it’s pretty simple:
import clr

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

from Autodesk.Revit.DB import *

rot_enum = {'None' : ViewportRotation.None,
            'CW' : ViewportRotation.Clockwise,
            'CCW' : ViewportRotation.Counterclockwise}

rot = IN[0]
viewports = UnwrapElement(IN[1])

rotation = rot_enum[rot]
for v in viewports:
    v.Rotation = rotation
OUT = 0

Also I noticed you asked this already here:
Could you please just bump up the old thread next time? That way we’ll keep the forums nice and tidy.


as an alternate idea- would it be easier to apply a rotated scope box to the view ?


Hi Venkov,
It is awsome, I give it a try now. Thanks


Hi Venkov,
I try your routine but this is same the the option rotate view on sheet of revit. it rotate the whole view including anotation…
Any chance, we just rotate the crop view only, thanks


If you want finer grained control, then I suggest you use Scope boxes as Andrew suggested. You’ll find examples on how to select and apply them if you search the forum.

It should be possible to rotate a view’s crop region directly with the API’s “ElementTransformUtils.RotateElement” method but I wouldn’t recommend it.

Why not? It’s pretty simple. Here’s some code:

    def RotateCropBox(view, cropBox, angle):
        doc = DocumentManager.Instance.CurrentDBDocument
	bbox = view.CropBox
	center = 0.5 * (bbox.Max + bbox.Min)
	axis = Line.CreateBound(center, center + XYZ.BasisZ)
	ElementTransformUtils.RotateElement(doc, cropBox.Id, axis, angle)
	return view

Now the trick of course is to get the proper angle to rotate the view by, because I am guessing that you are looking to align it with some element in view (wall, grid etc.). To get view crop box I was using a little trick that Jeremy Tammik shared on his blog:

def GetViewCropBoxElement(view):
	doc = DocumentManager.Instance.CurrentDBDocument
	tGroup = TransactionGroup(doc, "Temp to find crop box element")
	trans1 = Transaction(doc, "Temp to find crop box element")
	view.CropBoxVisible = False
	shownElems = FilteredElementCollector(doc, view.Id).ToElementIds()
	view.CropBoxVisible = True
	cropBoxElement = FilteredElementCollector(doc, view.Id).Excluding(shownElems).FirstElement()
	return cropBoxElement

What happens here is that you turn off the crop box, select everything in view, then create exclusion filter for all these elements, then turn the crop box back on and select everything but previously selected things. This should leave you with the only new thing visible in view: CROP BOX.

I will leave the rest for you to figure out.



I wouldn’t really recommend it because in my humble view it’s bad BIM :stuck_out_tongue_winking_eye:

Once somebody rotates a view by an odd angle (i.e.12.4130245212 degrees) and forgets to document the change anywhere, there’s no quick way to rotate it back to its original position. Even worse, if you do attempt to shift it back manually and eff up the n-th digit (or a floating point number does its things and muddies things for you), your model accuracy will suffer and you might expose yourself to numerous annoying line misalignment warnings and other errors.

That’s why it’s better to use scope boxes (or the True North view setting) because you can quickly and safely go back to the view’s original state and continue modeling as usual.

This is great code and there’s definitely some isolated cases where you have no other choice but to modify the crop box but I’d only resort to that if I don’t have any other alternatives.


Spoken like a true BIM Manager. +1 for that.

…on the other hand where is the adventurous, Bad Monkey, I want to break Revit in half spirit? :stuck_out_tongue_winking_eye:


Hello Konrad,

For the 180degrees rotation of multiple sections I have tried to use the code you supplied, however I am unable to get it to work. So I have a few questions; Of what type are the 3 inputs (view, cropbox, angle)? And why am I getting this error?

Warning: Cannot find static method or constructor Autodesk.DesignScript.Geometry.Line.Createbound()
I used the code in a code block(had to make a few syntax changes), is that the right way?

Thanks in advance