Pin Views on Sheets Using Python and Revit API

Hi,
Here, the Pinned property is based on the Element Class and not on the ElementId class

Your question was taken from the Revit API forum.
With Dynamo it’s still simpler :wink:.

doc = DocumentManager.Instance.CurrentDBDocument

coll_sheets=FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Sheets).WhereElementIsNotElementType().ToElements()


viewport_id=[ViewSheet.GetAllViewports(s) for s in coll_sheets]
viewport=[doc.GetElement(i) for j in range(len(viewport_id)) for i in viewport_id[j]]

TransactionManager.Instance.EnsureInTransaction(doc)
for v in viewport:
    v.Pinned=True
TransactionManager.Instance.TransactionTaskDone()


OUT = coll_sheets,viewport_id,viewport

Sincerely
christian.stan