Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Meyer <florianfelix@web.de>2010-05-15 03:30:29 +0400
committerFlorian Meyer <florianfelix@web.de>2010-05-15 03:30:29 +0400
commit9216515dfd0a62ea79d2637dbf545cba76a9526e (patch)
treea5159e3d92cceaebdffeb7b208a989998faa3257 /add_mesh_pipe_joint.py
parent34be323f5e8a0db339c814c98374b456df5202b2 (diff)
- same view_align fix as in gears
Diffstat (limited to 'add_mesh_pipe_joint.py')
-rw-r--r--add_mesh_pipe_joint.py62
1 files changed, 43 insertions, 19 deletions
diff --git a/add_mesh_pipe_joint.py b/add_mesh_pipe_joint.py
index beea04cd..803d79e5 100644
--- a/add_mesh_pipe_joint.py
+++ b/add_mesh_pipe_joint.py
@@ -145,25 +145,26 @@ def store_recall_properties(ob, op, op_args):
# Apply view rotation to objects if "Align To" for
# new objects was set to "VIEW" in the User Preference.
-def apply_object_align(context, ob):
- obj_align = bpy.context.user_preferences.edit.object_align
-
+# 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'):
- view3d = context.space_data
- region = view3d.region_3d
- viewMatrix = region.view_matrix
- rot = viewMatrix.rotation_part()
- ob.rotation_euler = rot.invert().to_euler()
-
-
+ 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).
# name ... Name of the new mesh (& object).
# edit ... Replace existing mesh data.
# Note: Using "edit" will destroy/delete existing mesh data.
-def create_mesh_object(context, verts, edges, faces, name, edit):
+def create_mesh_object(context, verts, edges, faces, name, edit, newMatrix):
scene = context.scene
obj_act = scene.objects.active
@@ -216,9 +217,7 @@ def create_mesh_object(context, verts, edges, faces, name, edit):
ob_new.selected = True
# Place the object at the 3D cursor location.
- ob_new.location = scene.cursor_location
-
- apply_object_align(context, ob_new)
+ ob_new.matrix = newMatrix
if obj_act and obj_act.mode == 'EDIT':
if not edit:
@@ -359,6 +358,7 @@ class AddElbowJoint(bpy.types.Operator):
min=0.01,
max=100.0,
unit="LENGTH")
+ newMatrix = mathutils.Matrix()
def execute(self, context):
edit = self.properties.edit
@@ -419,7 +419,7 @@ class AddElbowJoint(bpy.types.Operator):
faces.extend(createFaces(loop2, loop3, closed=True))
obj = create_mesh_object(context, verts, [], faces,
- "Elbow Joint", edit)
+ "Elbow Joint", edit, self.newMatrix)
# Store 'recall' properties in the object.
recall_args_list = {
@@ -433,6 +433,10 @@ class AddElbowJoint(bpy.types.Operator):
return {'FINISHED'}
+ def invoke(self, context, event):
+ self.newMatrix = align_matrix(context)
+ self.execute(context)
+ return {'FINISHED'}
class AddTeeJoint(bpy.types.Operator):
# Create the vertices and polygons for a simple tee (T) joint.
@@ -488,6 +492,7 @@ class AddTeeJoint(bpy.types.Operator):
min=0.01,
max=100.0,
unit="LENGTH")
+ newMatrix = mathutils.Matrix()
def execute(self, context):
edit = self.properties.edit
@@ -615,7 +620,7 @@ class AddTeeJoint(bpy.types.Operator):
faces.extend(createFaces(loopJoint2, loopArm, closed=True))
faces.extend(createFaces(loopJoint3, loopMainEnd, closed=True))
- obj = create_mesh_object(context, verts, [], faces, "Tee Joint", edit)
+ obj = create_mesh_object(context, verts, [], faces, "Tee Joint", edit, self.newMatrix)
# Store 'recall' properties in the object.
recall_args_list = {
@@ -630,6 +635,10 @@ class AddTeeJoint(bpy.types.Operator):
return {'FINISHED'}
+ def invoke(self, context, event):
+ self.newMatrix = align_matrix(context)
+ self.execute(context)
+ return {'FINISHED'}
class AddWyeJoint(bpy.types.Operator):
'''Add a Wye-Joint mesh'''
@@ -689,6 +698,7 @@ class AddWyeJoint(bpy.types.Operator):
min=0.01,
max=100.0,
unit="LENGTH")
+ newMatrix = mathutils.Matrix()
def execute(self, context):
edit = self.properties.edit
@@ -827,7 +837,7 @@ class AddWyeJoint(bpy.types.Operator):
faces.extend(createFaces(loopJoint2, loopArm1, closed=True))
faces.extend(createFaces(loopJoint3, loopArm2, closed=True))
- obj = create_mesh_object(context, verts, [], faces, "Wye Joint", edit)
+ obj = create_mesh_object(context, verts, [], faces, "Wye Joint", edit, self.newMatrix)
# Store 'recall' properties in the object.
recall_args_list = {
@@ -843,6 +853,10 @@ class AddWyeJoint(bpy.types.Operator):
return {'FINISHED'}
+ def invoke(self, context, event):
+ self.newMatrix = align_matrix(context)
+ self.execute(context)
+ return {'FINISHED'}
class AddCrossJoint(bpy.types.Operator):
'''Add a Cross-Joint mesh'''
@@ -913,6 +927,7 @@ class AddCrossJoint(bpy.types.Operator):
min=0.01,
max=100.0,
unit="LENGTH")
+ newMatrix = mathutils.Matrix()
def execute(self, context):
edit = self.properties.edit
@@ -1102,7 +1117,7 @@ class AddCrossJoint(bpy.types.Operator):
faces.extend(createFaces(loopJoint4, loopArm3, closed=True))
obj = create_mesh_object(context, verts, [], faces,
- "Cross Joint", edit)
+ "Cross Joint", edit, self.newMatrix)
# Store 'recall' properties in the object.
recall_args_list = {
@@ -1120,6 +1135,10 @@ class AddCrossJoint(bpy.types.Operator):
return {'FINISHED'}
+ def invoke(self, context, event):
+ self.newMatrix = align_matrix(context)
+ self.execute(context)
+ return {'FINISHED'}
class AddNJoint(bpy.types.Operator):
'''Add a N-Joint mesh'''
@@ -1156,6 +1175,7 @@ class AddNJoint(bpy.types.Operator):
min=0.01,
max=100.0,
unit="LENGTH")
+ newMatrix = mathutils.Matrix()
def execute(self, context):
edit = self.properties.edit
@@ -1280,7 +1300,7 @@ class AddNJoint(bpy.types.Operator):
createFaces(loopsJoints[loopIdx],
loopsEndCircles[loopIdx], closed=True))
- obj = create_mesh_object(context, verts, [], faces, "N Joint", edit)
+ obj = create_mesh_object(context, verts, [], faces, "N Joint", edit, self.newMatrix)
# Store 'recall' properties in the object.
recall_args_list = {
@@ -1293,6 +1313,10 @@ class AddNJoint(bpy.types.Operator):
return {'FINISHED'}
+ def invoke(self, context, event):
+ self.newMatrix = align_matrix(context)
+ self.execute(context)
+ return {'FINISHED'}
class INFO_MT_mesh_pipe_joints_add(bpy.types.Menu):
# Define the "Pipe Joints" menu