fix [#34851] "UnitSettings.scale_length" not beeing calculated the same way for all objects

This commit is contained in:
Campbell Barton
2013-05-28 23:07:16 +00:00
parent abfee7425b
commit de3686ac25
3 changed files with 57 additions and 16 deletions

View File

@@ -22,6 +22,9 @@ __all__ = (
"add_object_align_init",
"object_data_add",
"AddObjectHelper",
"object_add_grid_scale",
"object_add_grid_scale_apply_operator",
"object_image_guess",
)
@@ -210,6 +213,21 @@ def object_add_grid_scale(context):
return 1.0
def object_add_grid_scale_apply_operator(operator, context):
"""
Scale an operators distance values by the grid size.
"""
grid_scale = object_add_grid_scale(context)
properties = operator.properties
properties_def = properties.bl_rna.properties
for prop_id in properties_def.keys():
if not properties.is_property_set(prop_id):
prop_def = properties_def[prop_id]
if prop_def.unit == 'LENGTH' and prop_def.subtype == 'DISTANCE':
setattr(operator, prop_id, getattr(operator, prop_id) * grid_scale)
def object_image_guess(obj, bm=None):
"""
Return a single image used by the object,