[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1081] trunk/py/scripts/addons/ space_view3d_align_tools.py: V0.13

Gabriel Beaudin gabhead at hotmail.com
Sun Sep 26 07:49:17 CEST 2010


Revision: 1081
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1081
Author:   gabhead
Date:     2010-09-26 07:49:15 +0200 (Sun, 26 Sep 2010)

Log Message:
-----------
V0.13

Modified Paths:
--------------
    trunk/py/scripts/addons/space_view3d_align_tools.py

Modified: trunk/py/scripts/addons/space_view3d_align_tools.py
===================================================================
--- trunk/py/scripts/addons/space_view3d_align_tools.py	2010-09-26 01:06:59 UTC (rev 1080)
+++ trunk/py/scripts/addons/space_view3d_align_tools.py	2010-09-26 05:49:15 UTC (rev 1081)
@@ -15,324 +15,290 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
 # ***** END GPL LICENCE BLOCK *****
 
 bl_addon_info = {
-    "name": "Align Tools",
-    "author": "Gabriel Beaudin (gabhead)",
-    "version": (0,1),
-    "blender": (2, 5, 3),
-    "api": 31965,
-    "location": "Tool Shelf",
-    "description": "Align selected objects to the active object",
-    "warning": "",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
-        "Scripts/3D interaction/Align_Tools",
-    "tracker_url": "https://projects.blender.org/tracker/index.php?"\
-        "func=detail&aid==22389&group_id=153&atid=468",
-    "category": "3D View"}
+    'name': '3D View: Align Tools',
+    'author': 'Gabriel Beaudin (gabhead)',
+    'version': (0,13),
+    'blender': (2, 5, 4),
+    'location': 'Tool Shelf',
+    'description': 'Align selected objects to the active object',
+    'wiki_url':
+    'http://wiki.blender.org/index.php/Extensions:2.5/Py/' \
+        'Scripts/3D interaction/Align_Tools',
+    'tracker_url': 'https://projects.blender.org/tracker/index.php?'\
+        'func=detail&aid==22389&group_id=153&atid=468',
+    'category': '3D View'}
 
-"""Align Selected Objects"""
 
 import bpy
+from bpy.props import *
+#import Mathutils
+sce = bpy.context.scene
 
+##interface
+######################
 
 class AlignUi(bpy.types.Panel):
-    bl_space_type = 'VIEW_3D'
-    bl_region_type = 'TOOLS'
-
     bl_label = "Align Tools"
     bl_context = "objectmode"
-
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'TOOLS'
+    
     def draw(self, context):
         layout = self.layout
-        obj = context.object
+        obj = bpy.context.object
+        sce = bpy.context.scene
+        items_list = [("Min", "Minimum", "Minimum"),
+                  ("Max", "Maximum", "Maximum",),
+                  ("Center","Center","Center"),
+                  ("Origin","Origin","Origin")]
 
-        if obj != None:
-            row = layout.row()
-            row.label(text="Active object is: ", icon='OBJECT_DATA')
-            row = layout.row()
-            row.label(obj.name, icon='EDITMODE_HLT')
-        
-        box = layout.separator()
-        
-        col = layout.column()
-        col.label(text="Align Loc + Rot:", icon='MANIPUL')
+        bpy.types.Scene.SrcLocation = EnumProperty(name="SrcLocation",
+                                 items=items_list,
+                                 description="SrcLocation",
+                                 default="Origin")
 
-        
-        col = layout.column(align=False)
-        col.operator("object.AlignObjects",text="XYZ")
-        
-        col = layout.column()
-        col.label(text="Align Location:", icon='MAN_TRANS')
+        items_list = [("Min", "Minimum", "Minimum"),
+                  ("Max", "Maximum", "Maximum",),
+                  ("Center","Center","Center"),
+                  ("Origin","Origin","Origin")]
 
-        col = layout.column_flow(columns=5,align=True)
-        col.operator("object.AlignObjectsLocationX",text="X")
-        col.operator("object.AlignObjectsLocationY",text="Y")
-        col.operator("object.AlignObjectsLocationZ",text="Z")
-        col.operator("object.AlignObjectsLocationAll",text="All")
+        bpy.types.Scene.ActLocation = EnumProperty(
+                                 name="ActLocation",
+                                 items=items_list,
+                                 description="ActLocation",
+                                 default="Origin")
 
-        col = layout.column()
-        col.label(text="Align Rotation:", icon='MAN_ROT')
+        bpy.types.Scene.Aling_LocationX = BoolProperty(
+            name="Aling_LocationX",
+            attr="Aling_LocationX",
+            description="Aling_LocationX",
+            default=0)
 
-        col = layout.column_flow(columns=5,align=True)
-        col.operator("object.AlignObjectsRotationX",text="X")
-        col.operator("object.AlignObjectsRotationY",text="Y")
-        col.operator("object.AlignObjectsRotationZ",text="Z")
-        col.operator("object.AlignObjectsRotationAll",text="All")
-        
-        col = layout.column()
-        col.label(text="Align Scale:", icon='MAN_SCALE')
+        bpy.types.Scene.Aling_LocationY=BoolProperty(
+            name="Aling_LocationY",
+            attr="Aling_LocationY",
+            description="Aling_LocationY",
+            default=0)
 
-        col = layout.column_flow(columns=5,align=True)
-        col.operator("object.AlignObjectsScaleX",text="X")
-        col.operator("object.AlignObjectsScaleY",text="Y")
-        col.operator("object.AlignObjectsScaleZ",text="Z")
-        col.operator("object.AlignObjectsScaleAll",text="All")
+        bpy.types.Scene.Aling_LocationZ=BoolProperty(
+            name="Aling_LocationZ",
+            attr="Aling_LocationZ",
+            description="Aling_LocationZ",
+            default=0)
 
+        bpy.types.Scene.Aling_RotationX=BoolProperty(
+            name="Aling_RotationX",
+            attr="Aling_RotationX",
+            description="Aling_LocationX",
+            default=0)
 
-##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
+        bpy.types.Scene.Aling_RotationY=BoolProperty(
+            name="Aling_RotationY",
+            attr="Aling_RotationY",
+            description="Aling_LocationY",
+            default=0)
 
-## Align Location
+        bpy.types.Scene.Aling_RotationZ=BoolProperty(
+            name="Aling_RotationZ",
+            attr="Aling_RotationZ",
+            description="Aling_LocationZ",
+            default=0)
 
-def LocAll(context):
-    for i in bpy.context.selected_objects:
-        i.location = bpy.context.active_object.location
+        bpy.types.Scene.Aling_ScaleX=BoolProperty(
+            name="Aling_ScaleX",
+            attr="Aling_ScaleX",
+            description="Aling_LocationX",
+            default=0)
 
-def LocX(context):
-    for i in bpy.context.selected_objects:
-        i.location.x = bpy.context.active_object.location.x
+        bpy.types.Scene.Aling_ScaleY=BoolProperty(
+            name="Aling_ScaleY",
+            attr="Aling_ScaleY",
+            description="Aling_LocationY",
+            default=0)
 
-def LocY(context):
-    for i in bpy.context.selected_objects:
-        i.location.y = bpy.context.active_object.location.y
+        bpy.types.Scene.Aling_ScaleZ=BoolProperty(
+            name="Aling_ScaleZ",
+            attr="Aling_ScaleZ",
+            description="Aling_LocationZ",
+            default=0)
 
-def LocZ(context):
-    for i in bpy.context.selected_objects:
-        i.location.z = bpy.context.active_object.location.z
+        if len(bpy.context.selected_objects)>1:
+            
+            col = layout.column()
+            bo = layout.box()
+            bo.prop_menu_enum(data=sce,property="SrcLocation",text=str((len(bpy.context.selected_objects))-1)+" objects: "+sce.SrcLocation,icon='OBJECT_DATA')
+            if bpy.context.object != None:
+                bo.prop_menu_enum(data=sce,property="ActLocation",text="To: "+obj.name+": "+sce.ActLocation,icon='OBJECT_DATA')
 
-## Aling Rotation
-def RotAll(context):
-    for i in bpy.context.selected_objects:
-        i.rotation_euler = bpy.context.active_object.rotation_euler
+            col = layout.column()
+            col.label(text="Align Location:", icon='MAN_TRANS')
+        		
+            col = layout.column_flow(columns=3,align=True)
+            col.prop(sce,"Aling_LocationX",text="X")
+            col.prop(sce,"Aling_LocationY",text="Y")
+            col.prop(sce,"Aling_LocationZ",text="Z")
 
-def RotX(context):
-    for i in bpy.context.selected_objects:
-        i.rotation_euler.x = bpy.context.active_object.rotation_euler.x
+            col = layout.column()
+            col.label(text="Align Rotation:", icon='MAN_ROT')
 
-def RotY(context):
-    for i in bpy.context.selected_objects:
-        i.rotation_euler.y = bpy.context.active_object.rotation_euler.y
+            col = layout.column_flow(columns=3,align=True)
+            col.prop(sce,"Aling_RotationX",text="X")
+            col.prop(sce,"Aling_RotationY",text="Y")
+            col.prop(sce,"Aling_RotationZ",text="Z")
 
-def RotZ(context):
-    for i in bpy.context.selected_objects:
-        i.rotation_euler.z = bpy.context.active_object.rotation_euler.z
-## Aling Scale
-def ScaleAll(context):
-    for i in bpy.context.selected_objects:
-        i.scale = bpy.context.active_object.scale
+            col = layout.column()
+            col.label(text="Align Scale:", icon='MAN_SCALE')
 
-def ScaleX(context):
-    for i in bpy.context.selected_objects:
-        i.scale.x = bpy.context.active_object.scale.x
+            col = layout.column_flow(columns=3,align=True)
+            col.prop(sce,"Aling_ScaleX",text="X")
+            col.prop(sce,"Aling_ScaleY",text="Y")
+            col.prop(sce,"Aling_ScaleZ",text="Z")
 
-def ScaleY(context):
-    for i in bpy.context.selected_objects:
-        i.scale.y = bpy.context.active_object.scale.y
+            col = layout.column(align=False)
+            col.operator("object.AlignObjects",text="Align")
+##Methods
+##################
 
-def ScaleZ(context):
-    for i in bpy.context.selected_objects:
-        i.scale.z = bpy.context.active_object.scale.z
+##Get World Verts location
 
-## Classes
+def VertCoordSysLocalToWorld(obj):
+    NewList = []
 
-## Align All Rotation And Location
+    for i in obj.data.vertices:
+        WorldVert=(obj.matrix_world*i.co)-obj.location
+        NewList.append(WorldVert)
+    return NewList
+
+##Create World bound_box
+def CreateWorldBoundBox(obj):
+    World_bound_box = []
+    Xlist=[]
+    Ylist=[]
+    Zlist=[]
+    
+    #separate X Y and Z
+    for i in VertCoordSysLocalToWorld(obj):
+        Xlist.append(i.x)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list