Rotate crop views on sheet

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

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitAPI')
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]
TransactionManager.Instance.EnsureInTransaction(doc)
for v in viewports:
    v.Rotation = rotation
TransactionManager.Instance.TransactionTaskDone()
OUT = 0

Also I noticed you asked this already here:
https://forum.dynamobim.com/t/rotate-multiple-view-on-sheet/3880
Could you please just bump up the old thread next time? That way we’ll keep the forums nice and tidy.

4 Likes