diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-07-25 10:40:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-07-25 10:40:16 +0400 |
commit | 4f4eeb826aaae7ed5909fd6e5f718c0fb3b3a441 (patch) | |
tree | 07d03a3486bf84ba4344d40c14ae6fc087232c91 /release/scripts/startup/bl_operators/object_align.py | |
parent | 6065390f4ccae14cabc1bac294d34598a7e90dbf (diff) |
style changes for operator scripts & some pep8 edits.
Diffstat (limited to 'release/scripts/startup/bl_operators/object_align.py')
-rw-r--r-- | release/scripts/startup/bl_operators/object_align.py | 104 |
1 files changed, 58 insertions, 46 deletions
diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index 952a2328ca9..2a7ae0c993b 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -16,102 +16,107 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> import bpy from mathutils import Vector def GlobalBB_LQ(bb_world): - + # Initialize the variables with the 8th vertex - left, right, front, back, down, up =\ - bb_world[7][0],\ - bb_world[7][0],\ - bb_world[7][1],\ - bb_world[7][1],\ - bb_world[7][2],\ - bb_world[7][2] - + left, right, front, back, down, up = (bb_world[7][0], + bb_world[7][0], + bb_world[7][1], + bb_world[7][1], + bb_world[7][2], + bb_world[7][2], + ) + # Test against the other 7 verts for i in range (7): - + # X Range val = bb_world[i][0] if val < left: left = val - + if val > right: right = val - + # Y Range val = bb_world[i][1] if val < front: front = val - + if val > back: back = val - + # Z Range val = bb_world[i][2] if val < down: down = val - + if val > up: up = val - + return (Vector((left, front, up)), Vector((right, back, down))) def GlobalBB_HQ(obj): - + matrix_world = obj.matrix_world.copy() - + # Initialize the variables with the last vertex - + verts = obj.data.vertices - + val = verts[-1].co * matrix_world - - left, right, front, back, down, up =\ - val[0],\ - val[0],\ - val[1],\ - val[1],\ - val[2],\ - val[2] - + + left, right, front, back, down, up = (val[0], + val[0], + val[1], + val[1], + val[2], + val[2], + ) + # Test against all other verts for i in range (len(verts)-1): - + vco = verts[i].co * matrix_world - + # X Range val = vco[0] if val < left: left = val - + if val > right: right = val - + # Y Range val = vco[1] if val < front: front = val - + if val > back: back = val - + # Z Range val = vco[2] if val < down: down = val - + if val > up: up = val - - return (Vector((left, front, up)), Vector((right, back, down))) + return Vector((left, front, up)), Vector((right, back, down)) -def align_objects(align_x, align_y, align_z, align_mode, relative_to, bb_quality): + +def align_objects(align_x, + align_y, + align_z, + align_mode, + relative_to, + bb_quality): cursor = bpy.context.scene.cursor_location @@ -131,12 +136,12 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to, bb_quality return False for obj, bb_world in objs: - + if bb_quality: GBB = GlobalBB_HQ(obj) else: GBB = GlobalBB_LQ(bb_world) - + Left_Front_Up = GBB[0] Right_Back_Down = GBB[1] @@ -194,12 +199,12 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to, bb_quality for obj, bb_world in objs: bb_world = [Vector(v[:]) * obj.matrix_world for v in obj.bound_box] - + if bb_quality: GBB = GlobalBB_HQ(obj) else: GBB = GlobalBB_LQ(bb_world) - + Left_Front_Up = GBB[0] Right_Back_Down = GBB[1] @@ -339,7 +344,9 @@ class AlignObjects(bpy.types.Operator): bb_quality = BoolProperty( name="High Quality", - description="Enables high quality calculation of the bounding box for perfect results on complex shape meshes with rotation/scale (Slow)", + description=("Enables high quality calculation of the " + "bounding box for perfect results on complex " + "shape meshes with rotation/scale (Slow)"), default=True) align_mode = EnumProperty(items=( @@ -374,7 +381,12 @@ class AlignObjects(bpy.types.Operator): def execute(self, context): align_axis = self.align_axis - ret = align_objects('X' in align_axis, 'Y' in align_axis, 'Z' in align_axis, self.align_mode, self.relative_to, self.bb_quality) + ret = align_objects('X' in align_axis, + 'Y' in align_axis, + 'Z' in align_axis, + self.align_mode, + self.relative_to, + self.bb_quality) if not ret: self.report({'WARNING'}, "No objects with bound-box selected") |