diff --git a/add_mesh_BoltFactory/Boltfactory.py b/add_mesh_BoltFactory/Boltfactory.py index f2646704467b1a757ae1a516ac6a67bacf347109..58a7ae011ccad53bc6eaf2e89fad99ca39b397d3 100644 --- a/add_mesh_BoltFactory/Boltfactory.py +++ b/add_mesh_BoltFactory/Boltfactory.py @@ -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)