\${prefix}_\${level}_\${discipline}# Batch Rename Views — Dynamo Python Script import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument prefix = IN[0] nameFormat = IN[1] views = FilteredElementCollector(doc)\ .OfClass(View).ToElements() renamed, errors = [], [] TransactionManager.Instance.EnsureInTransaction(doc) for v in views: if v.IsTemplate: continue newName = nameFormat.replace("{prefix}", prefix) try: v.Name = newName; renamed.append(v) except Exception as e: errors.append(str(e)) TransactionManager.Instance.ForceCloseTransaction() OUT = [renamed, [v.Name for v in renamed], errors]
# Export Room Data to CSV import clr, csv clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * from RevitServices.Persistence import DocumentManager doc = DocumentManager.Instance.CurrentDBDocument out_path = IN[0] SQFT_TO_SQM = 0.092903 rooms = FilteredElementCollector(doc)\ .OfCategory(BuiltInCategory.OST_Rooms).ToElements() rows = [] for r in rooms: if r.Area == 0: continue dept = r.LookupParameter("Department") rows.append([r.Number, r.Name, round(r.Area * SQFT_TO_SQM, 2), dept.AsString() if dept else ""]) with open(out_path, "w", newline="") as f: csv.writer(f).writerows(rows) OUT = [out_path, len(rows)]
# Place Furniture on a Regular Grid import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument sx, sy = IN[1] / 304.8, IN[2] / 304.8 cx, cy = int(IN[3]), int(IN[4]) sym = next((fs for fs in FilteredElementCollector(doc).OfClass(FamilySymbol) if fs.Family.Name == IN[5] and fs.Name == IN[6]),None) level = FilteredElementCollector(doc)\ .OfClass(Level).FirstElement() placed = [] TransactionManager.Instance.EnsureInTransaction(doc) if not sym.IsActive: sym.Activate() for row in range(cy): for col in range(cx): pt = XYZ(col * sx, row * sy, 0) placed.append(doc.Create.NewFamilyInstance( pt, sym, level, Structure.StructuralType.NonStructural)) TransactionManager.Instance.ForceCloseTransaction() OUT = [placed, len(placed)]