Skip to content

Commit

Permalink
feat: add adaptive unit fallback support for both metric (meters) and…
Browse files Browse the repository at this point in the history
… imperial (feet)
  • Loading branch information
tristan-hm committed Jan 31, 2023
1 parent 5a79e34 commit 23435b4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def get_scene_unit_factor():
return 1.0

units = {
'ADAPTIVE' : 1,
'KILOMETERS' : 1000,
'METERS' : 1,
'CENTIMETERS': 0.01,
Expand All @@ -50,6 +49,12 @@ def get_scene_unit_factor():
'THOU' : 0.0254 / 1000,
}

if bpy.context.scene.unit_settings.length_unit == 'ADAPTIVE':
if bpy.context.scene.unit_settings.system == 'METRIC':
return units['METERS']
if bpy.context.scene.unit_settings.system == 'IMPERIAL':
return units['FEET']

return units[bpy.context.scene.unit_settings.length_unit]


Expand All @@ -58,7 +63,6 @@ def get_scene_unit_suffix():
return ""

units = {
'ADAPTIVE' : 'm',
'KILOMETERS' : 'km',
'METERS' : 'm',
'CENTIMETERS': 'cm',
Expand All @@ -70,4 +74,10 @@ def get_scene_unit_suffix():
'THOU' : 'thou',
}

if bpy.context.scene.unit_settings.length_unit == 'ADAPTIVE':
if bpy.context.scene.unit_settings.system == 'METRIC':
return units['METERS']
if bpy.context.scene.unit_settings.system == 'IMPERIAL':
return units['FEET']

return units[bpy.context.scene.unit_settings.length_unit]

0 comments on commit 23435b4

Please sign in to comment.