Skip to content

Commit 11e76a3

Browse files
authored
Merge pull request #2950 from Wurschdhaud/fix-2949
wrap editfamily in try except to catch non revit errors
2 parents 08378b5 + 089ecee commit 11e76a3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/Tools.stack/Inspect.pulldown/ListFamilySizeCreator.pushbutton/ListFamilySizeCreator_script.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pyrevit import revit, forms, script, DB, HOST_APP
88

99
output = script.get_output()
10+
logger = script.get_logger()
1011

1112
FIELDS = ["Size", "Name", "Category", "Creator", "Count"]
1213
# temporary path for saving families
@@ -150,14 +151,19 @@ def print_sorted(families, group_by):
150151
for fam in all_fams:
151152
with revit.ErrorSwallower() as swallower:
152153
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
154162
fam_path = fam_doc.PathName
155163
# if the family path does not exists, save it temporary
156164
# only if the wasn't opened when the script was started
157165
if fam_doc.Title not in opened_families and (
158166
not fam_path or not os.path.exists(fam_path)):
159-
# edit family
160-
fam_doc = revit.doc.EditFamily(fam)
161167
# save with temporary path, to know family size
162168
fam_path = os.path.join(temp_dir, fam_doc.Title)
163169
fam_doc.SaveAs(fam_path, save_as_options)

0 commit comments

Comments
 (0)