From a9fa6efcde330570bd9837a1085a34ef4aac3222 Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Wed, 26 Jan 2011 14:59:57 +0000
Subject: [PATCH] patch [#25632] Get rid of obsolete magic edit property from
 Lawrence D'Oliveiro (ldo)

---
 add_mesh_ant_landscape.py |  86 +++++++++----------------------
 add_mesh_extras.py        | 103 ++++++++++----------------------------
 add_mesh_gears.py         |  90 +++++++++------------------------
 add_mesh_gemstones.py     |  90 +++++++++------------------------
 add_mesh_solid.py         |  81 ++++++++----------------------
 add_mesh_twisted_torus.py |  82 ++++++++----------------------
 6 files changed, 141 insertions(+), 391 deletions(-)

diff --git a/add_mesh_ant_landscape.py b/add_mesh_ant_landscape.py
index 6e220572f..896f7fe27 100644
--- a/add_mesh_ant_landscape.py
+++ b/add_mesh_ant_landscape.py
@@ -19,8 +19,8 @@
 bl_info = {
     "name": "ANT Landscape",
     "author": "Jimmy Hazevoet",
-    "version": (0,1,0),
-    "blender": (2, 5, 4),
+    "version": (0,1,1),
+    "blender": (2, 5, 6),
     "api": 32411,
     "location": "Add Mesh menu",
     "description": "Adds a landscape primitive",
@@ -94,16 +94,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)
 
@@ -116,60 +110,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
-
-            # Clear users of existing mesh datablock.
-            old_mesh.user_clear()
+    # Always create new object
+    ob_new = bpy.data.objects.new(name, mesh)
 
-            # Remove old mesh datablock if no users are left.
-            if (old_mesh.users == 0):
-                bpy.data.meshes.remove(old_mesh)
+    # Link new object to the given scene and select it.
+    scene.objects.link(ob_new)
+    ob_new.select = True
 
-            # 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.
@@ -521,12 +489,6 @@ class landscape_add(bpy.types.Operator):
     bl_options = {'REGISTER', 'UNDO'}
     bl_description = "Add landscape mesh"
 
-    # edit - Whether to add or update.
-    edit = BoolProperty(name="",
-        description="",
-        default=False,
-        options={'HIDDEN'})
-
     # align_matrix for the invoke
     align_matrix = Matrix()
 
@@ -820,8 +782,6 @@ class landscape_add(bpy.types.Operator):
     # Execute
     def execute(self, context):
 
-        edit = self.edit
-
         #mesh update
         if self.AutoUpdate != 0:
 
@@ -869,7 +829,7 @@ class landscape_add(bpy.types.Operator):
                 verts, faces = grid_gen( self.Subdivision, self.MeshSize, options )
 
             # create mesh object
-            obj = create_mesh_object(context, verts, [], faces, "Landscape", edit, self.align_matrix)
+            obj = create_mesh_object(context, verts, [], faces, "Landscape", self.align_matrix)
 
             # sphere, remove doubles
             if self.SphereMesh !=0:
diff --git a/add_mesh_extras.py b/add_mesh_extras.py
index ab5292b51..1c7639323 100644
--- a/add_mesh_extras.py
+++ b/add_mesh_extras.py
@@ -19,8 +19,8 @@
 bl_info = {
     "name": "Extras",
     "author": "Pontiac, Fourmadmen, meta-androcto",
-    "version": (0,4),
-    "blender": (2, 5, 5),
+    "version": (0, 5),
+    "blender": (2, 5, 6),
     "api": 33832,
     "location": "View3D > Add > Mesh > Extras",
     "description": "Adds Star, Wedge, & Sqorus objects.",
@@ -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.
@@ -460,11 +428,6 @@ class AddSqorus(bpy.types.Operator):
     bl_label = "Add Sqorus"
     bl_options = {'REGISTER', 'UNDO'}
 
-    # edit - Whether to add or update.
-    edit = BoolProperty(name="",
-        description="",
-        default=False,
-        options={'HIDDEN'})
     hole_size = FloatProperty(name="Hole Size",
         description="Size of the Hole",
         min=0.01,
@@ -485,7 +448,7 @@ class AddSqorus(bpy.types.Operator):
 
         # Create mesh object (and meshdata)
         obj = create_mesh_object(context, verts, [], faces, "Sqorus",
-            self.edit, self.align_matrix)
+            self.align_matrix)
 
         return {'FINISHED'}
 
@@ -500,11 +463,6 @@ class AddWedge(bpy.types.Operator):
     bl_label = "Add Wedge"
     bl_options = {'REGISTER', 'UNDO'}
 
-    # edit - Whether to add or update.
-    edit = BoolProperty(name="",
-        description="",
-        default=False,
-        options={'HIDDEN'})
     size_x = FloatProperty(name="Size X",
         description="Size along the X axis",
         min=0.01,
@@ -530,7 +488,7 @@ class AddWedge(bpy.types.Operator):
             self.size_z)
 
         obj = create_mesh_object(context, verts, [], faces, "Wedge",
-            self.edit, self.align_matrix)
+            self.align_matrix)
 
         return {'FINISHED'}
 
@@ -546,11 +504,6 @@ class AddStar(bpy.types.Operator):
     bl_label = "Add Star"
     bl_options = {'REGISTER', 'UNDO'}
 
-    # edit - Whether to add or update.
-    edit = BoolProperty(name="",
-        description="",
-        default=False,
-        options={'HIDDEN'})
     points = IntProperty(name="Points",
         description="Number of points for the star",
         min=2,
@@ -582,7 +535,7 @@ class AddStar(bpy.types.Operator):
             self.height)
 
         obj = create_mesh_object(context, verts, [], faces, "Star",
-            self.edit, self.align_matrix)
+            self.align_matrix)
 
         return {'FINISHED'}
 
@@ -608,10 +561,6 @@ class AddTrapezohedron(bpy.types.Operator):
     height = FloatProperty(name = "Tip height",
                 description = "Height of the tip",
                 default = 1, min = 0.01, max = 100.0)
-    edit = BoolProperty(name="",
-                        description="",
-                        default=False,
-                        options={'HIDDEN'})
     align_matrix = Matrix()
     def execute(self,context):
         # generate mesh
@@ -620,7 +569,7 @@ class AddTrapezohedron(bpy.types.Operator):
                                     self.height)
         
         obj = create_mesh_object(context, verts, [], faces, "Trapazohedron",
-            self.edit, self.align_matrix)
+            self.align_matrix)
 
         return {'FINISHED'}
 
diff --git a/add_mesh_gears.py b/add_mesh_gears.py
index 22b4728cd..22ae52868 100644
--- a/add_mesh_gears.py
+++ b/add_mesh_gears.py
@@ -22,8 +22,8 @@
 bl_info = {
     "name": "Gears",
     "author": "Michel J. Anders (varkenvarken)",
-    "version": (2,4,1),
-    "blender": (2, 5, 3),
+    "version": (2, 4, 2),
+    "blender": (2, 5, 6),
     "api": 32411,
     "location": "View3D > Add > Mesh > Gears ",
     "description": "Adds a mesh Gear to the Add Mesh menu",
@@ -86,16 +86,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)
 
@@ -108,61 +102,35 @@ 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.
@@ -691,11 +659,6 @@ class AddGear(bpy.types.Operator):
     bl_label = "Add Gear"
     bl_options = {'REGISTER', 'UNDO'}
 
-    # edit - Whether to add or update.
-    edit = BoolProperty(name="",
-        description="",
-        default=False,
-        options={'HIDDEN'})
     number_of_teeth = IntProperty(name="Number of Teeth",
         description="Number of teeth on the gear",
         min=2,
@@ -781,7 +744,7 @@ class AddGear(bpy.types.Operator):
             crown=self.crown)
 
         # Actually create the mesh object from this geometry data.
-        obj = create_mesh_object(context, verts, [], faces, "Gear", self.edit, self.align_matrix)
+        obj = create_mesh_object(context, verts, [], faces, "Gear", self.align_matrix)
 
         # Create vertex groups from stored vertices.
         tipGroup = obj.vertex_groups.new('Tips')
@@ -803,11 +766,6 @@ class AddWormGear(bpy.types.Operator):
     bl_label = "Add Worm Gear"
     bl_options = {'REGISTER', 'UNDO'}
 
-    # edit - Whether to add or update.
-    edit = BoolProperty(name="",
-        description="",
-        default=False,
-        options={'HIDDEN'})
     number_of_teeth = IntProperty(name="Number of Teeth",
         description="Number of teeth on the gear",
         min=2,
@@ -885,7 +843,7 @@ class AddWormGear(bpy.types.Operator):
 
         # Actually create the mesh object from this geometry data.
         obj = create_mesh_object(context, verts, [], faces, "Worm Gear",
-            self.edit, self.align_matrix)
+            self.align_matrix)
 
         # Create vertex groups from stored vertices.
         tipGroup = obj.vertex_groups.new('Tips')
diff --git a/add_mesh_gemstones.py b/add_mesh_gemstones.py
index 9dd147a10..1ebcc4eb4 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'}
 
diff --git a/add_mesh_solid.py b/add_mesh_solid.py
index 63f657e17..507358630 100644
--- a/add_mesh_solid.py
+++ b/add_mesh_solid.py
@@ -20,7 +20,7 @@
 bl_info = {
     "name": "Regular Solids",
     "author": "DreamPainter",
-    "version": (1,),
+    "version": (1, 0, 1),
     "blender": (2, 5, 3),
     "api": 32411,
     "location": "View3D > Add > Mesh > Regular Solids",
@@ -58,16 +58,10 @@ def apply_object_align(context, ob):
 # 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):
     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)
 
@@ -80,61 +74,35 @@ def create_mesh_object(context, verts, edges, faces, name, edit):
     # 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
+    # Always create new object
+    ob_new = bpy.data.objects.new(name, mesh)
 
-        if obj_act.mode == 'OBJECT':
-            # Get existing mesh datablock.
-            old_mesh = ob_new.data
+    # Link new object to the given scene and select it.
+    scene.objects.link(ob_new)
+    ob_new.select = True
 
-            # Set object data to nothing
-            ob_new.data = None
+    # Place the object at the 3D cursor location.
+    ob_new.location = scene.cursor_location
 
-            # 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.location = scene.cursor_location
-
-        apply_object_align(context, ob_new)
+    apply_object_align(context, ob_new)
 
     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.
@@ -735,11 +703,6 @@ class Solids(bpy.types.Operator):
          "ds12":["12",1.1235,0.68,1,"L"],
          "c":["6",0,0,0,"0"],
          "sb":["20",2/3,0,0,"0"]}
-    
-    edit = BoolProperty(name="",
-                        description="",
-                        default=False,
-                        options={'HIDDEN'})
 
     def execute(self,context):
         # turn off undo for better performance (3 - 5x faster), also makes sure
@@ -774,7 +737,7 @@ class Solids(bpy.types.Operator):
         verts = [i*rad for i in verts]
 
         # generate object
-        obj = create_mesh_object(context,verts,[],faces,"Solid",self.edit)
+        obj = create_mesh_object(context,verts,[],faces,"Solid")
 
         # vertices will be on top of each other in some cases,
         #    so remove doubles then
diff --git a/add_mesh_twisted_torus.py b/add_mesh_twisted_torus.py
index d50fb20e1..195dcad81 100644
--- a/add_mesh_twisted_torus.py
+++ b/add_mesh_twisted_torus.py
@@ -23,7 +23,7 @@
 bl_info = {
     "name": "Twisted Torus",
     "author": "Paulo_Gomes",
-    "version": (0,11),
+    "version": (0, 11, 1),
     "blender": (2, 5, 3),
     "api": 32411,
     "location": "View3D > Add > Mesh ",
@@ -69,16 +69,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)
 
@@ -90,61 +84,34 @@ def create_mesh_object(context, verts, edges, faces, name, edit, align_matrix):
 
     # Deselect all objects.
     bpy.ops.object.select_all(action='DESELECT')
+    # Always create new object
+    ob_new = bpy.data.objects.new(name, mesh)
 
-    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()
+    # 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.
@@ -274,11 +241,6 @@ class AddTwistedTorus(bpy.types.Operator):
     bl_label = "Add Torus"
     bl_options = {'REGISTER', 'UNDO'}
 
-    # edit - Whether to add or update.
-    edit = BoolProperty(name="",
-        description="",
-        default=False,
-        options={'HIDDEN'})
     major_radius = FloatProperty(name="Major Radius",
         description="Radius from the origin to the" \
             " center of the cross section",
@@ -337,7 +299,7 @@ class AddTwistedTorus(bpy.types.Operator):
 
         # Actually create the mesh object from this geometry data.
         obj = create_mesh_object(context, verts, [], faces, "TwistedTorus",
-            self.edit, self.align_matrix)
+            self.align_matrix)
 
         return {'FINISHED'}
 
-- 
GitLab