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:
authorCampbell Barton <ideasman42@gmail.com>2011-01-26 17:59:57 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-01-26 17:59:57 +0300
commita9fa6efcde330570bd9837a1085a34ef4aac3222 (patch)
treef6a4a98683960ba3d05aefca91b12ead944c7b7d /add_mesh_gemstones.py
parent9700b00900b672355c76fd8795221d05ff2e0140 (diff)
patch [#25632] Get rid of obsolete magic edit property
from Lawrence D'Oliveiro (ldo)
Diffstat (limited to 'add_mesh_gemstones.py')
-rw-r--r--add_mesh_gemstones.py90
1 files changed, 24 insertions, 66 deletions
diff --git a/add_mesh_gemstones.py b/add_mesh_gemstones.py
index 9dd147a1..1ebcc4eb 100644
--- a/add_mesh_gemstones.py
+++ b/add_mesh_gemstones.py
@@ -19,8 +19,8 @@
bl_info = {
"name": "Gemstones",
"author": "Pontiac, Fourmadmen, Dreampainter",
- "version": (0,3),
- "blender": (2, 5, 3),
+ "version": (0, 4),
+ "blender": (2, 5, 6),
"api": 32411,
"location": "View3D > Add > Mesh > Gemstones",
"description": "Adds various gemstone (Diamond & Gem) meshes.",
@@ -53,16 +53,10 @@ def align_matrix(context):
# 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):
+def create_mesh_object(context, verts, edges, faces, name, 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
-
# Create new mesh
mesh = bpy.data.meshes.new(name)
@@ -75,60 +69,34 @@ def create_mesh_object(context, verts, edges, faces, name, edit, align_matrix):
# Deselect all objects.
bpy.ops.object.select_all(action='DESELECT')
- 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
+ # Always create new object
+ ob_new = bpy.data.objects.new(name, mesh)
- # Clear users of existing mesh datablock.
- old_mesh.user_clear()
+ # Link new object to the given scene and select it.
+ scene.objects.link(ob_new)
+ ob_new.select = True
- # 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.
- # apply viewRotaion
- ob_new.matrix_world = align_matrix
+ # Place the object at the 3D cursor location.
+ # apply viewRotaion
+ 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')
+ # We are in EditMode, switch to ObjectMode.
+ bpy.ops.object.mode_set(mode='OBJECT')
- # Select the active object as well.
- obj_act.select = True
+ # Select the active object as well.
+ obj_act.select = 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')
- ob_new = obj_act
+ ob_new = obj_act
else:
# We are in ObjectMode.
@@ -327,11 +295,6 @@ class AddDiamond(bpy.types.Operator):
bl_label = "Add Diamond"
bl_options = {'REGISTER', 'UNDO'}
- # edit - Whether to add or update.
- edit = BoolProperty(name="",
- description="",
- default=False,
- options={'HIDDEN'})
segments = IntProperty(name="Segments",
description="Number of segments for the diamond",
min=3,
@@ -367,7 +330,7 @@ class AddDiamond(bpy.types.Operator):
self.pavilion_height)
obj = create_mesh_object(context, verts, [], faces,
- "Diamond", self.edit, self.align_matrix)
+ "Diamond", self.align_matrix)
return {'FINISHED'}
@@ -383,11 +346,6 @@ class AddGem(bpy.types.Operator):
bl_description = "Create an offset faceted gem."
bl_options = {'REGISTER', 'UNDO'}
- # edit - Whether to add or update.
- edit = BoolProperty(name="",
- description="",
- default=False,
- options={'HIDDEN'})
segments = IntProperty(name="Segments",
description="Longitudial segmentation",
min=3,
@@ -425,7 +383,7 @@ class AddGem(bpy.types.Operator):
self.pavilion_height,
self.crown_height)
- obj = create_mesh_object(context, verts, [], faces, "Gem", self.edit, self.align_matrix)
+ obj = create_mesh_object(context, verts, [], faces, "Gem", self.align_matrix)
return {'FINISHED'}