[Bf-extensions-cvs] [e347b967] master: Align Tools: Update panel Rename

lijenstina noreply at git.blender.org
Mon Jul 10 00:23:33 CEST 2017


Commit: e347b967e204e1110c5da53dbd6371da433882b8
Author: lijenstina
Date:   Mon Jul 10 00:22:30 2017 +0200
Branches: master
https://developer.blender.org/rBACe347b967e204e1110c5da53dbd6371da433882b8

Align Tools: Update panel Rename

Bumped version to 0.3.2
Pep8 Cleanup
Remove unused imports
As a part of the task T50726:
Update the Panel rename code to more generic one
Use tuple imports for bpy.types
Consistent prop definitions
Fix typo using o.type instead of obj.type
Update wiki link
Add missing bl_description to operators
Small UI changes
No other functional changes

===================================================================

M	space_view3d_align_tools.py

===================================================================

diff --git a/space_view3d_align_tools.py b/space_view3d_align_tools.py
index 919f6191..f9f24b49 100644
--- a/space_view3d_align_tools.py
+++ b/space_view3d_align_tools.py
@@ -21,87 +21,113 @@
 bl_info = {
     "name": "Align Tools",
     "author": "gabhead, Lell, Anfeo",
-    "version": (0, 3, 1),
+    "version": (0, 3, 2),
     "blender": (2, 77, 0),
     "location": "View3D > Tool Shelf > Tools",
     "description": "Align Selected Objects to Active Object",
     "warning": "",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
-        "Scripts/3D interaction/Align_Tools",
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
+                "Scripts/3D interaction/Align_Tools",
     "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
     "category": "3D View",
 }
 
 import bpy
-from bpy.props import EnumProperty, PointerProperty, FloatProperty, BoolProperty, FloatVectorProperty
-from mathutils import Vector, Matrix
-from math import *
-
-## Simple Align Defs ##
-
-## Align all
+from bpy.types import (
+        Operator,
+        Panel,
+        AddonPreferences,
+        )
+from bpy.props import (
+        EnumProperty,
+        BoolProperty,
+        FloatVectorProperty,
+        StringProperty,
+        )
+from mathutils import (
+        Vector,
+        Matrix,
+        )
+
+
+# Simple Align Defs #
+
+# Align all
 def main(context):
     for i in bpy.context.selected_objects:
         i.location = bpy.context.active_object.location
         i.rotation_euler = bpy.context.active_object.rotation_euler
 
-## Align Location
+
+# Align Location
 def LocAll(context):
     for i in bpy.context.selected_objects:
         i.location = bpy.context.active_object.location
 
+
 def LocX(context):
     for i in bpy.context.selected_objects:
         i.location.x = bpy.context.active_object.location.x
 
+
 def LocY(context):
     for i in bpy.context.selected_objects:
         i.location.y = bpy.context.active_object.location.y
 
+
 def LocZ(context):
     for i in bpy.context.selected_objects:
         i.location.z = bpy.context.active_object.location.z
 
-## Align Rotation
+
+# Align Rotation
 def RotAll(context):
     for i in bpy.context.selected_objects:
         i.rotation_euler = bpy.context.active_object.rotation_euler
 
+
 def RotX(context):
     for i in bpy.context.selected_objects:
         i.rotation_euler.x = bpy.context.active_object.rotation_euler.x
 
+
 def RotY(context):
     for i in bpy.context.selected_objects:
         i.rotation_euler.y = bpy.context.active_object.rotation_euler.y
 
+
 def RotZ(context):
     for i in bpy.context.selected_objects:
         i.rotation_euler.z = bpy.context.active_object.rotation_euler.z
 
-## Align Scale
+
+# Align Scale
 def ScaleAll(context):
     for i in bpy.context.selected_objects:
         i.scale = bpy.context.active_object.scale
 
+
 def ScaleX(context):
     for i in bpy.context.selected_objects:
         i.scale.x = bpy.context.active_object.scale.x
 
+
 def ScaleY(context):
     for i in bpy.context.selected_objects:
         i.scale.y = bpy.context.active_object.scale.y
 
+
 def ScaleZ(context):
     for i in bpy.context.selected_objects:
         i.scale.z = bpy.context.active_object.scale.z
 
-## Advanced Align Defs ##
+
+# Advanced Align Defs #
 
 # subject to object 0, 1 and 2 to pivot for cursor
 def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y, loc_z, ref1, ref2, loc_offset,
-        rot_x, rot_y, rot_z, rot_offset, scale_x, scale_y, scale_z, scale_offset,
-         fit_x, fit_y, fit_z):
+                   rot_x, rot_y, rot_z, rot_offset, scale_x, scale_y, scale_z, scale_offset,
+                   fit_x, fit_y, fit_z):
 
     sel_obj = bpy.context.selected_objects
     act_obj = bpy.context.active_object
@@ -142,19 +168,19 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
                 for p in me.vertices:
                     co_list.append(p.co)
 
-            elif o.type == 'SURFACE' and len(me.splines) > 0:
+            elif obj.type == 'SURFACE' and len(me.splines) > 0:
                 ok = True
                 for s in me.splines:
                     for p in s.points:
                         co_list.append(p.co)
-            elif o.type == 'FONT' and len(o.data.splines) > 0:
+            elif obj.type == 'FONT' and len(obj.data.splines) > 0:
                 ok = True
                 for s in me.splines:
                     for p in s.bezier_points:
                         co_list.append(p.co)
 
-        #if a valid point found
-        #proceed to calculate the extremes
+        # if a valid point found
+        # proceed to calculate the extremes
         if ok:
             max_x = co_list[0][0]
             min_x = co_list[0][0]
@@ -164,23 +190,28 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
             min_z = co_list[0][2]
 
             for v in co_list:
-
-                #the strings of the list compared with the smaller and more found
-                #in order to find the minor and major for each axis
+                # the strings of the list compared with the smaller and more found
+                # in order to find the minor and major for each axis
                 act_x = v[0]
-                if act_x > max_x:    max_x = act_x
-                if act_x < min_x:    min_x = act_x
+                if act_x > max_x:
+                    max_x = act_x
+                if act_x < min_x:
+                    min_x = act_x
 
                 act_y = v[1]
-                if act_y > max_y:    max_y = act_y
-                if act_y < min_y:    min_y = act_y
+                if act_y > max_y:
+                    max_y = act_y
+                if act_y < min_y:
+                    min_y = act_y
 
                 act_z = v[2]
-                if act_z > max_z:    max_z = act_z
-                if act_z < min_z:    min_z = act_z
+                if act_z > max_z:
+                    max_z = act_z
+                if act_z < min_z:
+                    min_z = act_z
 
         else:
-            #otherwise use the pivot object
+            # otherwise use the pivot object
             a = obj.location
             min_x = a[0]
             max_x = a[0]
@@ -196,7 +227,7 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
         reference_points = [min_x, center_x, max_x, min_y, center_y, max_y, min_z, center_z, max_z]
         return reference_points
 
-    def get_sel_ref(ref_co, sel_obj): #I look for the selection end points
+    def get_sel_ref(ref_co, sel_obj):  # I look for the selection end points
 
         sel_min = ref_co.copy()
         sel_max = ref_co.copy()
@@ -221,10 +252,10 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
                 if ref_max[2] > sel_max[2]:
                     sel_max[2] = ref_max[2]
 
-        return sel_min, sel_max;
+        return sel_min, sel_max
 
     def find_ref2_co(act_obj):
-        #It contains the coordinates of the reference point for the positioning
+        # It contains the coordinates of the reference point for the positioning
         if ref2 == "0":
             ref_points = get_reference_points(act_obj, "global")
             ref2_co = [ref_points[0], ref_points[3], ref_points[6]]
@@ -249,7 +280,7 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
 
         ref_points = get_reference_points(obj, "global")
 
-        if loc_x == True:
+        if loc_x is True:
             if ref1 == "0":
                 min_x = ref_points[0]
                 new_x = ref2_co[0] + (obj.location[0] - min_x) + loc_offset[0]
@@ -262,7 +293,7 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
                 max_x = ref_points[2]
                 new_x = ref2_co[0] - (max_x - obj.location[0]) + loc_offset[0]
             obj.location[0] = new_x
-        if loc_y == True:
+        if loc_y is True:
             if ref1 == "0":
                 min_y = ref_points[3]
                 new_y = ref2_co[1] + (obj.location[1] - min_y) + loc_offset[1]
@@ -275,7 +306,7 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
                 max_y = ref_points[5]
                 new_y = ref2_co[1] - (max_y - obj.location[1]) + loc_offset[1]
             obj.location[1] = new_y
-        if loc_z == True:
+        if loc_z is True:
             if ref1 == "0":
                 min_z = ref_points[6]
                 new_z = ref2_co[2] + (obj.location[2] - min_z) + loc_offset[2]
@@ -290,19 +321,19 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
             obj.location[2] = new_z
 
     def find_new_rotation(obj):
-        if rot_x == True:
+        if rot_x is True:
             obj.rotation_euler[0] = act_obj.rotation_euler[0] + rot_offset[0]
-        if rot_y == True:
+        if rot_y is True:
             obj.rotation_euler[1] = act_obj.rotation_euler[1] + rot_offset[1]
-        if rot_z == True:
+        if rot_z is True:
             obj.rotation_euler[2] = act_obj.rotation_euler[2] + rot_offset[2]
 
     def find_new_scale(obj):
-        if scale_x == True:
+        if scale_x is True:
             obj.scale[0] = act_obj.scale[0] + scale_offset[0]
-        if scale_y == True:
+        if scale_y is True:
             obj.scale[1] = act_obj.scale[1] + scale_offset[1]
-        if scale_z == True:
+        if scale_z is True:
             obj.scale[2] = act_obj.scale[2] + scale_offset[2]
 
     def find_new_dimensions(obj, ref_dim):
@@ -317,7 +348,6 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
             dim = ref_points[8] - ref_points[6]
             obj.scale[2] = (ref_dim[2] / dim) * act_obj.scale[2]
 
-
     def move_pivot(obj):
         me = obj.data
         vec_ref2_co = Vector(ref2_co)
@@ -373,16 +403,16 @@ def align_function(subject, active_too, consistent, self_or_active, loc_x, loc_y
                     ref_co = obj_mtx * ref_co
                     ok = True
                     break
-        #se n

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list