[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [668] trunk/py/scripts/addons: -wrapping and cleanup of view_align from previous commits
Florian Meyer
florianfelix at web.de
Sat May 15 16:42:10 CEST 2010
Revision: 668
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=668
Author: testscreenings
Date: 2010-05-15 16:42:10 +0200 (Sat, 15 May 2010)
Log Message:
-----------
-wrapping and cleanup of view_align from previous commits
Modified Paths:
--------------
trunk/py/scripts/addons/add_mesh_gears.py
trunk/py/scripts/addons/add_mesh_pipe_joint.py
Modified: trunk/py/scripts/addons/add_mesh_gears.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_gears.py 2010-05-15 04:32:55 UTC (rev 667)
+++ trunk/py/scripts/addons/add_mesh_gears.py 2010-05-15 14:42:10 UTC (rev 668)
@@ -67,6 +67,18 @@
from math import *
from bpy.props import *
+# calculates the matrix for the new object
+# depending on user pref
+def align_matrix(context):
+ loc = mathutils.TranslationMatrix(context.scene.cursor_location)
+ obj_align = context.user_preferences.edit.object_align
+ if (context.space_data.type == 'VIEW_3D'
+ and obj_align == 'VIEW'):
+ rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
+ else:
+ rot = mathutils.Matrix()
+ newMatrix = loc * rot
+ return newMatrix
# Stores the values of a list of properties and the
# operator id in a property group ('recall_op') inside the object.
@@ -818,14 +830,7 @@
return {'FINISHED'}
def invoke(self, context, event):
- loc = mathutils.TranslationMatrix(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.Matrix()
- self.newMatrix = loc * rot
+ self.newMatrix = align_matrix(context)
self.execute(context)
return {'FINISHED'}
@@ -947,14 +952,7 @@
return {'FINISHED'}
def invoke(self, context, event):
- loc = mathutils.TranslationMatrix(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.Matrix()
- self.newMatrix = loc * rot
+ self.newMatrix = align_matrix(context)
self.execute(context)
return {'FINISHED'}
Modified: trunk/py/scripts/addons/add_mesh_pipe_joint.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_pipe_joint.py 2010-05-15 04:32:55 UTC (rev 667)
+++ trunk/py/scripts/addons/add_mesh_pipe_joint.py 2010-05-15 14:42:10 UTC (rev 668)
@@ -146,7 +146,18 @@
# Apply view rotation to objects if "Align To" for
# new objects was set to "VIEW" in the User Preference.
# Is now handled in the invoke functions
-
+# calculates the matrix for the new object
+# depending on user pref
+def align_matrix(context):
+ loc = mathutils.TranslationMatrix(context.scene.cursor_location)
+ obj_align = context.user_preferences.edit.object_align
+ if (context.space_data.type == 'VIEW_3D'
+ and obj_align == 'VIEW'):
+ rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
+ else:
+ rot = mathutils.Matrix()
+ newMatrix = loc * rot
+ return newMatrix
# Create a new mesh (object) from verts/edges/faces.
# verts/edges/faces ... List of vertices/edges/faces for the
# new mesh (as used in from_pydata).
@@ -423,14 +434,7 @@
return {'FINISHED'}
def invoke(self, context, event):
- loc = mathutils.TranslationMatrix(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.Matrix()
- self.newMatrix = loc * rot
+ self.newMatrix = align_matrix(context)
self.execute(context)
return {'FINISHED'}
@@ -632,14 +636,7 @@
return {'FINISHED'}
def invoke(self, context, event):
- loc = mathutils.TranslationMatrix(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.Matrix()
- self.newMatrix = loc * rot
+ self.newMatrix = align_matrix(context)
self.execute(context)
return {'FINISHED'}
@@ -857,14 +854,7 @@
return {'FINISHED'}
def invoke(self, context, event):
- loc = mathutils.TranslationMatrix(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.Matrix()
- self.newMatrix = loc * rot
+ self.newMatrix = align_matrix(context)
self.execute(context)
return {'FINISHED'}
@@ -1146,14 +1136,7 @@
return {'FINISHED'}
def invoke(self, context, event):
- loc = mathutils.TranslationMatrix(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.Matrix()
- self.newMatrix = loc * rot
+ self.newMatrix = align_matrix(context)
self.execute(context)
return {'FINISHED'}
@@ -1331,14 +1314,7 @@
return {'FINISHED'}
def invoke(self, context, event):
- loc = mathutils.TranslationMatrix(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.Matrix()
- self.newMatrix = loc * rot
+ self.newMatrix = align_matrix(context)
self.execute(context)
return {'FINISHED'}
More information about the Bf-extensions-cvs
mailing list