Unpin All Viewports

How do you undo, or unpin all viewports on a sheet? I’ve looked, and I can’t seem to find.

Collect the viewports. To filter the viewports you can check what sheet they are on by:


To unpin or pin is a boolean property:

from Autodesk.Revit.DB import(

from rpw import revit,db

doc = revit.doc
viewports = FilteredElementCollector(doc).OfClass(Viewport).ToElements()

with db.Transaction(doc=doc, name="Unpin Viewports"):
    for viewport in viewports:
        viewport.Pinned = False