Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'blenderkit/utils.py')
-rw-r--r--blenderkit/utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/blenderkit/utils.py b/blenderkit/utils.py
index 5bdace75..952219ad 100644
--- a/blenderkit/utils.py
+++ b/blenderkit/utils.py
@@ -741,6 +741,21 @@ def name_update(props):
# Here we actually rename assets datablocks, but don't do that with HDR's and possibly with others
asset.name = fname
+def fmt_dimensions(p):
+ '''formats dimensions to correct string'''
+ dims = [p['dimensionX'],p['dimensionY'],p['dimensionZ']]
+ maxl = max(dims)
+ if maxl>1:
+ unit = 'm'
+ unitscale = 1
+ elif maxl>.01:
+ unit = 'cm'
+ unitscale = 100
+ else:
+ unit = 'mm'
+ unitscale = 1000
+ s = f'{fmt_length(dims[0]*unitscale)}×{fmt_length(dims[1]*unitscale)}×{fmt_length(dims[2]*unitscale)} {unit}'
+ return s
def fmt_length(prop):
prop = str(round(prop, 2))