[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [507] trunk/py/scripts/addons/ add_mesh_pipe_joint.py: * Version 0.10.1
Martin Bürbaum
martin.buerbaum at gmx.at
Tue Mar 23 23:30:53 CET 2010
Revision: 507
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=507
Author: pontiac
Date: 2010-03-23 23:30:50 +0100 (Tue, 23 Mar 2010)
Log Message:
-----------
* Version 0.10.1
* Use hidden "edit" property for "recall" operator.
Modified Paths:
--------------
trunk/py/scripts/addons/add_mesh_pipe_joint.py
Modified: trunk/py/scripts/addons/add_mesh_pipe_joint.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_pipe_joint.py 2010-03-23 22:17:02 UTC (rev 506)
+++ trunk/py/scripts/addons/add_mesh_pipe_joint.py 2010-03-23 22:30:50 UTC (rev 507)
@@ -24,7 +24,7 @@
bl_addon_info = {
'name': 'Add Mesh: Pipe Joints',
'author': 'Buerbaum Martin (Pontiac)',
- 'version': '0.10',
+ 'version': '0.10.1',
'blender': (2, 5, 3),
'location': 'View3D > Add > Mesh > Pipe Joint',
'url':
@@ -46,6 +46,7 @@
Note: Currently only the "Elbow" type supports odd number of vertices.
Version history:
+v0.10.1 - Use hidden "edit" property for "recall" operator.
v0.10 - Store "recall" properties in the created objects.
Align the geometry to the view if the user preference says so.
v0.9.10 - Use bl_addon_info for Add-On information.
@@ -168,7 +169,7 @@
return faces
-def createObject(context, verts, faces, name):
+def createObject(context, verts, faces, name, edit):
'''Creates Meshes & Objects for the given lists of vertices and faces.'''
scene = context.scene
@@ -188,42 +189,57 @@
# bpy.types.Mesh.html#bpy.types.Mesh.from_pydata
mesh.from_pydata(verts, [], faces)
- # ugh - Deselect all objects.
- for ob in scene.objects:
- ob.selected = False
+ # Deselect all objects.
+ bpy.ops.object.select_all(action='DESELECT')
# Update mesh geometry after adding stuff.
mesh.update()
- # Create a new object.
- ob_new = bpy.data.objects.new(name, mesh)
+ if edit:
+ # Recreate geometry of existing object
+ obj_act = context.active_object
+ ob_new = obj_act
+
+ bpy.ops.object.mode_set(mode='EDIT')
+ bpy.ops.mesh.select_all(action='SELECT')
+ bpy.ops.mesh.delete(type='VERT')
+ bpy.ops.object.mode_set(mode='OBJECT')
+
+ ob_new.data = mesh
- # Link new object to the given scene and select it.
- scene.objects.link(ob_new)
- ob_new.selected = True
+ ob_new.selected = True
- # Place the object at the 3D cursor location.
- ob_new.location = scene.cursor_location
+ else:
+ # Create new object
+ ob_new = bpy.data.objects.new(name, mesh)
- obj_act = scene.objects.active
+ # Link new object to the given scene and select it.
+ scene.objects.link(ob_new)
+ ob_new.selected = True
- apply_view_rotation(context, ob_new)
+ # Place the object at the 3D cursor location.
+ ob_new.location = scene.cursor_location
+ obj_act = scene.objects.active
+
+ apply_view_rotation(context, ob_new)
+
if obj_act and obj_act.mode == 'EDIT':
- # We are in EditMode, switch to ObjectMode.
- bpy.ops.object.mode_set(mode='OBJECT')
+ 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.selected = True
+ # Select the active object as well.
+ obj_act.selected = True
- # Apply location of new object.
- scene.update()
+ # Apply location of new object.
+ scene.update()
- # Join new object into the active.
- bpy.ops.object.join()
+ # Join new object into the active.
+ bpy.ops.object.join()
- # Switching back to EditMode.
- bpy.ops.object.mode_set(mode='EDIT')
+ # Switching back to EditMode.
+ bpy.ops.object.mode_set(mode='EDIT')
else:
# We are in ObjectMode.
@@ -240,6 +256,12 @@
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,
@@ -272,6 +294,8 @@
unit="LENGTH")
def execute(self, context):
+ edit = self.properties.edit
+
radius = self.properties.radius
div = self.properties.div
@@ -327,10 +351,11 @@
faces.extend(createFaces(loop1, loop2))
faces.extend(createFaces(loop2, loop3))
- obj = createObject(context, verts, faces, "Elbow Joint")
+ obj = createObject(context, verts, faces, "Elbow Joint", edit)
# Store 'recall' properties in the object.
recall_prop_list = {
+ "edit": True,
"radius": radius,
"div": div,
"angle": angle,
@@ -349,6 +374,12 @@
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,
@@ -391,6 +422,8 @@
unit="LENGTH")
def execute(self, context):
+ edit = self.properties.edit
+
radius = self.properties.radius
div = self.properties.div
@@ -514,10 +547,11 @@
faces.extend(createFaces(loopJoint2, loopArm))
faces.extend(createFaces(loopJoint3, loopMainEnd))
- obj = createObject(context, verts, faces, "Tee Joint")
+ obj = createObject(context, verts, faces, "Tee Joint", edit)
# Store 'recall' properties in the object.
recall_prop_list = {
+ "edit": True,
"radius": radius,
"div": div,
"angle": angle,
@@ -535,6 +569,12 @@
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,
@@ -583,6 +623,8 @@
unit="LENGTH")
def execute(self, context):
+ edit = self.properties.edit
+
radius = self.properties.radius
div = self.properties.div
@@ -717,10 +759,11 @@
faces.extend(createFaces(loopJoint2, loopArm1))
faces.extend(createFaces(loopJoint3, loopArm2))
- obj = createObject(context, verts, faces, "Wye Joint")
+ obj = createObject(context, verts, faces, "Wye Joint", edit)
# Store 'recall' properties in the object.
recall_prop_list = {
+ "edit": True,
"radius": radius,
"div": div,
"angle1": angle1,
@@ -740,6 +783,12 @@
bl_label = "Add Pipe Cross-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,
@@ -798,6 +847,8 @@
unit="LENGTH")
def execute(self, context):
+ edit = self.properties.edit
+
radius = self.properties.radius
div = self.properties.div
@@ -982,10 +1033,11 @@
faces.extend(createFaces(loopJoint3, loopArm2))
faces.extend(createFaces(loopJoint4, loopArm3))
- obj = createObject(context, verts, faces, "Cross Joint")
+ obj = createObject(context, verts, faces, "Cross Joint", edit)
# Store 'recall' properties in the object.
recall_prop_list = {
+ "edit": True,
"radius": radius,
"div": div,
"angle1": angle1,
@@ -1007,6 +1059,12 @@
bl_label = "Add Pipe N-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,
@@ -1031,6 +1089,7 @@
unit="LENGTH")
def execute(self, context):
+ edit = self.properties.edit
radius = self.properties.radius
div = self.properties.div
number = self.properties.number
@@ -1152,10 +1211,11 @@
createFaces(loopsJoints[loopIdx],
loopsEndCircles[loopIdx]))
- obj = createObject(context, verts, faces, "N Joint")
+ obj = createObject(context, verts, faces, "N Joint", edit)
# Store 'recall' properties in the object.
recall_prop_list = {
+ "edit": True,
"radius": radius,
"div": div,
"number": number,
More information about the Bf-extensions-cvs
mailing list