[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1504] trunk/py/scripts/addons: patch [ #25632] Get rid of obsolete magic edit property
Campbell Barton
ideasman42 at gmail.com
Wed Jan 26 15:58:44 CET 2011
Revision: 1504
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1504
Author: campbellbarton
Date: 2011-01-26 14:58:43 +0000 (Wed, 26 Jan 2011)
Log Message:
-----------
patch [#25632] Get rid of obsolete magic edit property
from Lawrence D'Oliveiro (ldo)
for add_mesh_pipe_joint.py only.
Also use blender module for adding objects.
Modified Paths:
--------------
trunk/py/scripts/addons/add_mesh_3d_function_surface.py
trunk/py/scripts/addons/add_mesh_pipe_joint.py
Modified: trunk/py/scripts/addons/add_mesh_3d_function_surface.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_3d_function_surface.py 2011-01-26 14:43:56 UTC (rev 1503)
+++ trunk/py/scripts/addons/add_mesh_3d_function_surface.py 2011-01-26 14:58:43 UTC (rev 1504)
@@ -126,29 +126,11 @@
# properties (operator arguments/parameters).
-# calculates the matrix for the new object
-# depending on user pref
-def align_matrix(context):
- loc = Matrix.Translation(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
-
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- viewMat = context.space_data.region_3d.view_matrix
- rot = viewMat.rotation_part().invert().resize4x4()
- else:
- rot = Matrix()
- align_matrix = loc * rot
- return align_matrix
-
-
# 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).
-def create_mesh_object(context, verts, edges, faces, name, align_matrix):
- scene = context.scene
- obj_act = scene.objects.active
+def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
mesh = bpy.data.meshes.new(name)
@@ -160,7 +142,7 @@
mesh.update()
import add_object_utils
- add_object_utils.object_data_add(context, mesh, operator=None)
+ return add_object_utils.object_data_add(context, mesh, operator=None)
# A very simple "bridge" tool.
@@ -265,7 +247,6 @@
min=0.01,
max=100.0,
unit="LENGTH")
- align_matrix = Matrix()
def execute(self, context):
equation = self.equation
@@ -324,17 +305,11 @@
edgeloop_prev = edgeloop_cur
- obj = create_mesh_object(context, verts, [], faces,
- "Z Function", self.align_matrix)
+ base = create_mesh_object(context, verts, [], faces, "Z Function")
return {'FINISHED'}
- def invoke(self, context, event):
- self.align_matrix = align_matrix(context)
- self.execute(context)
- return {'FINISHED'}
-
def xyz_function_surface_faces(self, x_eq, y_eq, z_eq,
range_u_min, range_u_max, range_u_step, wrap_u,
range_v_min, range_v_max, range_v_step, wrap_v):
@@ -499,8 +474,6 @@
description="V Wrap around",
default=False)
- align_matrix = Matrix()
-
def execute(self, context):
verts, faces = xyz_function_surface_faces(
self,
@@ -519,17 +492,11 @@
if not verts:
return {'CANCELLED'}
- obj = create_mesh_object(context, verts, [], faces,
- "XYZ Function", self.align_matrix)
+ obj = create_mesh_object(context, verts, [], faces, "XYZ Function")
return {'FINISHED'}
- def invoke(self, context, event):
- self.align_matrix = align_matrix(context)
- self.execute(context)
- return {'FINISHED'}
-
################################
import space_info
Modified: trunk/py/scripts/addons/add_mesh_pipe_joint.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_pipe_joint.py 2011-01-26 14:43:56 UTC (rev 1503)
+++ trunk/py/scripts/addons/add_mesh_pipe_joint.py 2011-01-26 14:58:43 UTC (rev 1504)
@@ -19,7 +19,7 @@
bl_info = {
"name": "Pipe Joints",
"author": "Buerbaum Martin (Pontiac)",
- "version": (0, 10, 6),
+ "version": (0, 10, 7),
"blender": (2, 5, 3),
"api": 32411,
"location": "View3D > Add > Mesh > Pipe Joint",
@@ -134,38 +134,11 @@
from bpy.props import *
-# 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.Matrix.Translation(context.scene.cursor_location)
- obj_align = context.user_preferences.edit.object_align
- if (context.space_data.type == 'VIEW_3D'
- and obj_align == 'VIEW'):
- view_mat = context.space_data.region_3d.view_matrix
- rot = view_mat.rotation_part().invert().resize4x4()
- else:
- rot = mathutils.Matrix()
- align_matrix = loc * rot
- return align_matrix
-
-
# 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, align_matrix):
- scene = context.scene
- obj_act = scene.objects.active
-
- # Can't edit anything, unless we have an active obj.
- if edit and not obj_act:
- return None
-
+def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
mesh = bpy.data.meshes.new(name)
@@ -175,71 +148,9 @@
# Update mesh geometry after adding stuff.
mesh.update()
- # Deselect all objects.
- bpy.ops.object.select_all(action='DESELECT')
+ import add_object_utils
+ return add_object_utils.object_data_add(context, mesh, operator=None)
- if edit:
- # Replace geometry of existing object
-
- # Use the active obj and select it.
- ob_new = obj_act
- ob_new.select = True
-
- if obj_act.mode == 'OBJECT':
- # Get existing mesh datablock.
- old_mesh = ob_new.data
-
- # Set object data to nothing
- ob_new.data = None
-
- # Clear users of existing mesh datablock.
- old_mesh.user_clear()
-
- # Remove old mesh datablock if no users are left.
- if (old_mesh.users == 0):
- bpy.data.meshes.remove(old_mesh)
-
- # Assign new mesh datablock.
- ob_new.data = mesh
-
- else:
- # Create new object
- ob_new = bpy.data.objects.new(name, mesh)
-
- # Link new object to the given scene and select it.
- scene.objects.link(ob_new)
- ob_new.select = True
-
- # Place the object at the 3D cursor location.
- ob_new.matrix_world = align_matrix
-
- if obj_act and obj_act.mode == 'EDIT':
- if not edit:
- # We are in EditMode, switch to ObjectMode.
- bpy.ops.object.mode_set(mode='OBJECT')
-
- # Select the active object as well.
- obj_act.select = True
-
- # Apply location of new object.
- scene.update()
-
- # Join new object into the active.
- bpy.ops.object.join()
-
- # Switching back to EditMode.
- bpy.ops.object.mode_set(mode='EDIT')
-
- ob_new = obj_act
-
- else:
- # We are in ObjectMode.
- # Make the new object the active one.
- scene.objects.active = ob_new
-
- return ob_new
-
-
# A very simple "bridge" tool.
# Connects two equally long vertex rows with faces.
# Returns a list of the new faces (list of lists)
@@ -316,12 +227,6 @@
bl_label = "Add Pipe Elbow"
bl_options = {'REGISTER', 'UNDO'}
- # edit - Whether to add or update.
- edit = BoolProperty(name="",
- description="",
- default=False,
- options={'HIDDEN'})
-
radius = FloatProperty(name="Radius",
description="The radius of the pipe.",
default=1.0,
@@ -352,10 +257,8 @@
min=0.01,
max=100.0,
unit="LENGTH")
- align_matrix = mathutils.Matrix()
def execute(self, context):
- edit = self.edit
radius = self.radius
div = self.div
@@ -412,17 +315,11 @@
faces.extend(createFaces(loop1, loop2, closed=True))
faces.extend(createFaces(loop2, loop3, closed=True))
- obj = create_mesh_object(context, verts, [], faces,
- "Elbow Joint", edit, self.align_matrix)
+ base = create_mesh_object(context, verts, [], faces, "Elbow Joint")
return {'FINISHED'}
- def invoke(self, context, event):
- self.align_matrix = align_matrix(context)
- self.execute(context)
- return {'FINISHED'}
-
class AddTeeJoint(bpy.types.Operator):
# Create the vertices and polygons for a simple tee (T) joint.
# The base arm of the T can be positioned in an angle if needed though.
@@ -431,12 +328,6 @@
bl_label = "Add Pipe Tee-Joint"
bl_options = {'REGISTER', 'UNDO'}
- # edit - Whether to add or update.
- edit = BoolProperty(name="",
- description="",
- default=False,
- options={'HIDDEN'})
-
radius = FloatProperty(name="Radius",
description="The radius of the pipe.",
default=1.0,
@@ -477,10 +368,8 @@
min=0.01,
max=100.0,
unit="LENGTH")
- align_matrix = mathutils.Matrix()
def execute(self, context):
- edit = self.edit
radius = self.radius
div = self.div
@@ -605,29 +494,17 @@
faces.extend(createFaces(loopJoint2, loopArm, closed=True))
faces.extend(createFaces(loopJoint3, loopMainEnd, closed=True))
- obj = create_mesh_object(context, verts, [], faces,
- "Tee Joint", edit, self.align_matrix)
+ base = create_mesh_object(context, verts, [], faces, "Tee Joint")
return {'FINISHED'}
- def invoke(self, context, event):
- self.align_matrix = align_matrix(context)
- self.execute(context)
- return {'FINISHED'}
-
class AddWyeJoint(bpy.types.Operator):
'''Add a Wye-Joint mesh'''
bl_idname = "mesh.primitive_wye_joint_add"
bl_label = "Add Pipe Wye-Joint"
bl_options = {'REGISTER', 'UNDO'}
- # edit - Whether to add or update.
- edit = BoolProperty(name="",
- description="",
- default=False,
- options={'HIDDEN'})
-
radius = FloatProperty(name="Radius",
description="The radius of the pipe.",
default=1.0,
@@ -674,10 +551,8 @@
min=0.01,
max=100.0,
unit="LENGTH")
- align_matrix = mathutils.Matrix()
def execute(self, context):
- edit = self.edit
radius = self.radius
div = self.div
@@ -813,17 +688,11 @@
faces.extend(createFaces(loopJoint2, loopArm1, closed=True))
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list