[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4506] trunk/py/scripts/addons/ object_print3d_utils/operators.py: minor tweak to printing tools, report which axis is clamped.
Campbell Barton
ideasman42 at gmail.com
Mon May 6 09:16:27 CEST 2013
Revision: 4506
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4506
Author: campbellbarton
Date: 2013-05-06 07:16:27 +0000 (Mon, 06 May 2013)
Log Message:
-----------
minor tweak to printing tools, report which axis is clamped.
Modified Paths:
--------------
trunk/py/scripts/addons/object_print3d_utils/operators.py
Modified: trunk/py/scripts/addons/object_print3d_utils/operators.py
===================================================================
--- trunk/py/scripts/addons/object_print3d_utils/operators.py 2013-05-06 07:04:51 UTC (rev 4505)
+++ trunk/py/scripts/addons/object_print3d_utils/operators.py 2013-05-06 07:16:27 UTC (rev 4506)
@@ -489,14 +489,14 @@
# -----------
# Scale to...
-def _scale(scale, report=None):
+def _scale(scale, report=None, report_suffix=""):
if scale != 1.0:
bpy.ops.transform.resize(value=(scale,) * 3,
mirror=False, proportional='DISABLED',
snap=False,
texture_space=False)
if report is not None:
- report({'INFO'}, "Scaled by %s" % clean_float("%.6f" % scale))
+ report({'INFO'}, "Scaled by %s%s" % (clean_float("%.6f" % scale), report_suffix))
class Print3DScaleToVolume(Operator):
@@ -550,6 +550,9 @@
length_init = FloatProperty(
options={'HIDDEN'},
)
+ axis_init = IntProperty(
+ options={'HIDDEN'},
+ )
length = FloatProperty(
name="Length Limit",
unit='LENGTH',
@@ -558,22 +561,24 @@
def execute(self, context):
scale = self.length / self.length_init
- _scale(scale, self.report)
+ _scale(scale,
+ report=self.report,
+ report_suffix=", Clamping %s-Axis" % "XYZ"[self.axis_init])
return {'FINISHED'}
def invoke(self, context, event):
from mathutils import Vector
def calc_length(vecs):
- return max((max(v[i] for v in vecs) - min(v[i] for v in vecs)) for i in range(3))
+ return max(((max(v[i] for v in vecs) - min(v[i] for v in vecs)), i) for i in range(3))
if context.mode == 'EDIT_MESH':
- length = calc_length([Vector(v) * obj.matrix_world
- for v in context.edit_object.bound_box])
+ length, axis = calc_length([Vector(v) * obj.matrix_world
+ for v in context.edit_object.bound_box])
else:
- length = calc_length([Vector(v) * obj.matrix_world
- for obj in context.selected_editable_objects
- if obj.type == 'MESH' for v in obj.bound_box])
+ length, axis = calc_length([Vector(v) * obj.matrix_world
+ for obj in context.selected_editable_objects
+ if obj.type == 'MESH' for v in obj.bound_box])
self.length_init = self.length = length
More information about the Bf-extensions-cvs
mailing list