mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
remove the orphaned data created on object duplicate
orphaned mesh still had ifc_definition_id of the original object and could have caused issues in theory
This commit is contained in:
@@ -689,8 +689,11 @@ class OverrideDuplicateMove(bpy.types.Operator):
|
|||||||
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
|
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
|
||||||
|
|
||||||
new_obj = obj.copy()
|
new_obj = obj.copy()
|
||||||
|
temp_data = None
|
||||||
if obj.data:
|
if obj.data:
|
||||||
new_obj.data = obj.data.copy()
|
# assure root.copy_class won't replace the previous mesh globally
|
||||||
|
temp_data = obj.data.copy()
|
||||||
|
new_obj.data = temp_data
|
||||||
if obj == context.active_object:
|
if obj == context.active_object:
|
||||||
self.new_active_obj = new_obj
|
self.new_active_obj = new_obj
|
||||||
for collection in obj.users_collection:
|
for collection in obj.users_collection:
|
||||||
@@ -699,8 +702,13 @@ class OverrideDuplicateMove(bpy.types.Operator):
|
|||||||
new_obj.select_set(True)
|
new_obj.select_set(True)
|
||||||
# clear object's collection so it will be able to have it's own
|
# clear object's collection so it will be able to have it's own
|
||||||
new_obj.BIMObjectProperties.collection = None
|
new_obj.BIMObjectProperties.collection = None
|
||||||
# Copy the actual class
|
# copy the actual class
|
||||||
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
|
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
|
||||||
|
|
||||||
|
# clean up the orphaned mesh with ifc id of the original object to avoid confusion
|
||||||
|
if temp_data:
|
||||||
|
tool.Blender.remove_data_block(temp_data)
|
||||||
|
|
||||||
if new:
|
if new:
|
||||||
array_pset = ifcopenshell.util.element.get_pset(new, "BBIM_Array")
|
array_pset = ifcopenshell.util.element.get_pset(new, "BBIM_Array")
|
||||||
if array_pset:
|
if array_pset:
|
||||||
|
|||||||
@@ -387,6 +387,11 @@ class Blender:
|
|||||||
getattr(data_to, data_block_type).append(name)
|
getattr(data_to, data_block_type).append(name)
|
||||||
return {"data_block": getattr(data_to, data_block_type)[0], "msg": ""}
|
return {"data_block": getattr(data_to, data_block_type)[0], "msg": ""}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def remove_data_block(cls, data_block):
|
||||||
|
collection_name = repr(data_block).split(".", 2)[-1].split("[", 1)[0]
|
||||||
|
getattr(bpy.data, collection_name).remove(data_block)
|
||||||
|
|
||||||
## BMESH UTILS ##
|
## BMESH UTILS ##
|
||||||
@classmethod
|
@classmethod
|
||||||
def apply_bmesh(cls, mesh, bm, obj=None):
|
def apply_bmesh(cls, mesh, bm, obj=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user