Skip to content
Snippets Groups Projects
Commit 6b131222 authored by Robert Meerman's avatar Robert Meerman Committed by Aaron Keith
Browse files

Corrected "Change Bolt" removes linked duplicates

Patch D10034

Prior to this patch, attempting to modify an existing bolt would
*replace* the object's mesh data block with a new one and remove the
original. This removal would essentially delete all linked duplicates.

Now the original mesh data block is modified in place, which avoids
having to copy anything between new and old object data blocks
(materials, names, etc), and causes all linked duplicates to reflect
the changes as users would expect.
parent 6da09c30
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
import bpy
import bmesh
from mathutils import Matrix
from bpy.types import Operator
from bpy_extras.object_utils import AddObjectHelper
......@@ -431,20 +432,21 @@ class add_mesh_bolt(Operator, AddObjectHelper):
(context.active_object.data is not None) and ('Bolt' in context.active_object.data.keys()) and \
(self.change == True):
obj = context.active_object
oldmesh = obj.data
oldmeshname = obj.data.name
mesh = createMesh.Create_New_Mesh(self, context)
obj.data = mesh
# Modify existing mesh data object by replacing geometry (but leaving materials etc)
bm = bmesh.new()
bm.from_mesh(mesh)
bm.to_mesh(obj.data)
bm.free()
bpy.data.meshes.remove(mesh)
try:
bpy.ops.object.vertex_group_remove(all=True)
except:
pass
for material in oldmesh.materials:
obj.data.materials.append(material)
bpy.data.meshes.remove(oldmesh)
obj.data.name = oldmeshname
else:
mesh = createMesh.Create_New_Mesh(self, context)
obj = object_utils.object_data_add(context, mesh, operator=self)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment