Skip to content

Commit 1b5fc02

Browse files
committed
added changes suggested in #2657: use internal unit conversion, handle errors gracefully
1 parent 2457b55 commit 1b5fc02

File tree

1 file changed

+8
-5
lines changed
  • extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/ptools.stack/Links.pulldown/ListDWGs.pushbutton

1 file changed

+8
-5
lines changed

extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/ptools.stack/Links.pulldown/ListDWGs.pushbutton/ListDWGs_script.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
output = script.get_output()
11+
mlogger = script.get_logger()
1112

1213

1314
def listdwgs(current_view_only=False):
@@ -57,11 +58,13 @@ def listdwgs(current_view_only=False):
5758
transform = dwg.GetTransform()
5859
if transform:
5960
offset_z = transform.Origin.Z # in feet
60-
offset_z_m = round(
61-
offset_z * 0.3048, 3
62-
) # convert to meters, round for readability
63-
except:
64-
pass
61+
offset_z_m = DB.UnitUtils.ConvertFromInternalUnits(
62+
offset_z, DB.UnitTypeId.Meters
63+
)
64+
except Exception as ex:
65+
mlogger.debug(
66+
"Failed to convert offset Z from internal units: {}".format(ex)
67+
)
6568

6669
print("\n\n")
6770
output.print_md(

0 commit comments

Comments
 (0)