revit-apipyrevit

Getting access to a sheets Title block using python


Dynamo Script

Within Dynamo I was able to adjust the title block per sheet but I was requested to simplify it into a button click using python only.

I can find the sheets but I can not adjust the parameters per sheet. I believe this is because the parameter I am trying to toggle on and off is located within the Titleblock and not on the sheet it self. I thought maybe I would need to unwrap these but I could not get the function to work outside of Dynamo. Any help would be appreciated.

sheet_collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Sheets) \
                                           .WhereElementIsNotElementType() \
                                           .ToElements()
for sheet in sheet_collector:
    print(sheet.Name)

The snippet above is how I am sourcing all the sheets and I have been able to find everyone but when searching for the custome parameter, it comes up nil.


Solution

  • To get the FamilyInstance of the title block you can use this:

    var titleBlockFamInst = new FilteredElementCollector(doc, viewSheetId).OfCategory(BuiltInCategory.OST_TitleBlocks).FirstElement() as FamilyInstance;