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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-08-10 15:58:53 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-08-10 15:58:53 +0400
commit6c951fbb98a5ddb29240c3efc9af4304ab942396 (patch)
tree7eb917c4f8cb9196f1430cf034335d2d7ebaeb1e /release
parent7084be920a0acb95e2db84bb7029a65bc7a76d9a (diff)
adding back button evaluation so you can do 1/60, 90*0.1 etc as well as dimension conversion 1km-10cm+4ft
Note... - Python3.1 you don't need to add the .0 for divisions anymore (was esp annoying for button eval) - Simple dimension input, imperial mi/yd/ft/in, metric km/m/cm/mm, Later could display these values and have a pref for scene scale, atm it assumes 1BU == 1m.
Diffstat (limited to 'release')
-rw-r--r--release/ui/bpy_ops.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/release/ui/bpy_ops.py b/release/ui/bpy_ops.py
index aa9bfb460f0..1d79f1a331f 100644
--- a/release/ui/bpy_ops.py
+++ b/release/ui/bpy_ops.py
@@ -111,3 +111,48 @@ class bpy_ops_submodule_op(object):
import bpy
bpy.ops = bpy_ops()
+
+
+
+
+# A bit out of place but add button conversion code here
+module_type = type(__builtins__)
+import types
+mod = types.ModuleType('button_convert')
+
+import sys
+sys.modules['button_convert'] = mod
+
+def convert(expr):
+
+ def replace(string, unit, scaler):
+ # in need of regex
+ change = True
+ while change:
+ change = False
+ i = string.find(unit)
+ if i != -1:
+ if i>0 and not string[i-1].isalpha():
+ i_end = i+len(unit)
+ if i_end+1 >= len(string) or (not string[i_end+1].isalpha()):
+ string = string.replace(unit, scaler)
+ change = True
+ # print(string)
+ return string
+
+ #imperial
+ expr = replace(expr, 'mi', '*1609.344')
+ expr = replace(expr, 'yd', '*0.9144')
+ expr = replace(expr, 'ft', '*0.3048')
+ expr = replace(expr, 'in', '*0.0254')
+
+ # metric
+ expr = replace(expr, 'km', '*1000')
+ expr = replace(expr, 'm', '')
+ expr = replace(expr, 'cm', '*0.01')
+ expr = replace(expr, 'mm', '*0.001')
+
+ return expr
+
+mod.convert = convert
+