mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix bug where copying an instance did not auto link the meshes.
This commit is contained in:
@@ -26,6 +26,7 @@ def copy_class(ifc, collector, geometry, root, obj=None):
|
||||
relating_type = root.get_element_type(element)
|
||||
if relating_type and root.does_type_have_representations(relating_type):
|
||||
ifc.run("type.map_type_representations", related_object=element, relating_type=relating_type)
|
||||
root.link_object_data(ifc.get_object(relating_type), obj)
|
||||
else:
|
||||
representation = root.get_object_representation(obj)
|
||||
if representation:
|
||||
|
||||
@@ -160,6 +160,7 @@ class Root:
|
||||
def get_object_representation(cls, obj): pass
|
||||
def get_representation_context(cls, representation): pass
|
||||
def is_opening_element(cls, element): pass
|
||||
def link_object_data(cls, source_obj, destination_obj): pass
|
||||
def run_geometry_add_representation(cls, obj=None, context=None, ifc_representation_class=None, profile_set_usage=None): pass
|
||||
|
||||
|
||||
|
||||
@@ -61,6 +61,10 @@ class Root(blenderbim.core.tool.Root):
|
||||
def is_opening_element(cls, element):
|
||||
return element.is_a("IfcOpeningElement")
|
||||
|
||||
@classmethod
|
||||
def link_object_data(cls, source_obj, destination_obj):
|
||||
destination_obj.data = source_obj.data
|
||||
|
||||
@classmethod
|
||||
def run_geometry_add_representation(
|
||||
cls, obj=None, context=None, ifc_representation_class=None, profile_set_usage=None
|
||||
|
||||
@@ -33,6 +33,8 @@ class TestCopyClass:
|
||||
root.get_element_type("element").should_be_called().will_return("type")
|
||||
root.does_type_have_representations("type").should_be_called().will_return(True)
|
||||
ifc.run("type.map_type_representations", related_object="element", relating_type="type").should_be_called()
|
||||
ifc.get_object("type").should_be_called().will_return("type_obj")
|
||||
root.link_object_data("type_obj", "obj").should_be_called()
|
||||
collector.assign("obj").should_be_called()
|
||||
root.is_opening_element("element").should_be_called().will_return(False)
|
||||
subject.copy_class(ifc, collector, geometry, root, obj="obj")
|
||||
@@ -78,6 +80,8 @@ class TestCopyClass:
|
||||
root.get_element_type("element").should_be_called().will_return("type")
|
||||
root.does_type_have_representations("type").should_be_called().will_return(True)
|
||||
ifc.run("type.map_type_representations", related_object="element", relating_type="type").should_be_called()
|
||||
ifc.get_object("type").should_be_called().will_return("type_obj")
|
||||
root.link_object_data("type_obj", "obj").should_be_called()
|
||||
collector.assign("obj").should_be_called()
|
||||
root.is_opening_element("element").should_be_called().will_return(True)
|
||||
root.add_dynamic_opening_voids("element", "obj").should_be_called()
|
||||
|
||||
@@ -100,6 +100,16 @@ class TestIsOpeningElement(NewFile):
|
||||
assert subject.is_opening_element(ifc.createIfcOpeningElement()) is True
|
||||
|
||||
|
||||
class TestLinkObjectData(NewFile):
|
||||
def test_run(self):
|
||||
data = bpy.data.meshes.new("Mesh")
|
||||
source = bpy.data.objects.new("Object", data)
|
||||
destination = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
subject.link_object_data(source, destination)
|
||||
assert source.data == data
|
||||
assert source.data == destination.data
|
||||
|
||||
|
||||
class TestRunGeometryAddRepresntation(NewFile):
|
||||
def test_nothing(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user