|
7 | 7 | from pyrevit import revit, forms, script, DB, HOST_APP |
8 | 8 |
|
9 | 9 | output = script.get_output() |
| 10 | +logger = script.get_logger() |
10 | 11 |
|
11 | 12 | FIELDS = ["Size", "Name", "Category", "Creator", "Count"] |
12 | 13 | # temporary path for saving families |
@@ -150,14 +151,19 @@ def print_sorted(families, group_by): |
150 | 151 | for fam in all_fams: |
151 | 152 | with revit.ErrorSwallower() as swallower: |
152 | 153 | if fam.IsEditable: |
153 | | - fam_doc = revit.doc.EditFamily(fam) |
| 154 | + try: |
| 155 | + fam_doc = revit.doc.EditFamily(fam) |
| 156 | + except Exception as ex: |
| 157 | + logger.warning( |
| 158 | + "Skipping family '%s': could not open for edit: %s", |
| 159 | + fam.Name, ex |
| 160 | + ) |
| 161 | + continue |
154 | 162 | fam_path = fam_doc.PathName |
155 | 163 | # if the family path does not exists, save it temporary |
156 | 164 | # only if the wasn't opened when the script was started |
157 | 165 | if fam_doc.Title not in opened_families and ( |
158 | 166 | not fam_path or not os.path.exists(fam_path)): |
159 | | - # edit family |
160 | | - fam_doc = revit.doc.EditFamily(fam) |
161 | 167 | # save with temporary path, to know family size |
162 | 168 | fam_path = os.path.join(temp_dir, fam_doc.Title) |
163 | 169 | fam_doc.SaveAs(fam_path, save_as_options) |
|
0 commit comments