mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 14:07:43 +00:00
spatial.assign_container - support batching #4474
This commit is contained in:
@@ -47,7 +47,7 @@ def unassign_object(ifc, aggregate, collector, relating_obj=None, related_obj=No
|
||||
if relating_obj:
|
||||
ifc.run("aggregate.unassign_object", product=related_element)
|
||||
if container:
|
||||
ifc.run("spatial.assign_container", product=related_element, relating_structure=container)
|
||||
ifc.run("spatial.assign_container", products=[related_element], relating_structure=container)
|
||||
collector.assign(relating_obj)
|
||||
collector.assign(related_obj)
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ def unassign_object(ifc, nest, collector, relating_obj=None, related_obj=None):
|
||||
if relating_obj:
|
||||
ifc.run("nest.unassign_object", related_object=related_element)
|
||||
if container:
|
||||
ifc.run("spatial.assign_container", product=related_element, relating_structure=container)
|
||||
ifc.run("spatial.assign_container", products=[related_element], relating_structure=container)
|
||||
collector.assign(relating_obj)
|
||||
collector.assign(related_obj)
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ def assign_container(
|
||||
return
|
||||
rel = ifc.run(
|
||||
"spatial.assign_container",
|
||||
product=ifc.get_entity(element_obj),
|
||||
products=[ifc.get_entity(element_obj)],
|
||||
relating_structure=ifc.get_entity(structure_obj),
|
||||
)
|
||||
spatial.disable_editing(element_obj)
|
||||
|
||||
@@ -85,7 +85,9 @@ class Obj2Ifc:
|
||||
Name=mesh.label() or self.basename,
|
||||
Representation=representation,
|
||||
)
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, product=product, relating_structure=self.storey)
|
||||
ifcopenshell.api.run(
|
||||
"spatial.assign_container", self.file, products=[product], relating_structure=self.storey
|
||||
)
|
||||
product.ObjectPlacement = self.placement
|
||||
|
||||
self.file.write(self.outfile)
|
||||
|
||||
@@ -79,7 +79,9 @@ class Obj2Ifc:
|
||||
Name=mesh.name or self.basename,
|
||||
Representation=representation,
|
||||
)
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, product=product, relating_structure=self.storey)
|
||||
ifcopenshell.api.run(
|
||||
"spatial.assign_container", self.file, products=[product], relating_structure=self.storey
|
||||
)
|
||||
product.ObjectPlacement = self.placement
|
||||
|
||||
self.file.write(self.outfile)
|
||||
|
||||
@@ -53,7 +53,7 @@ class TestUnassignObject:
|
||||
def test_run(self, ifc, aggregate, collector):
|
||||
ifc.get_entity("related_obj").should_be_called().will_return("element")
|
||||
aggregate.get_container("element").should_be_called().will_return("container")
|
||||
ifc.run("spatial.assign_container", product="element", relating_structure="container").should_be_called()
|
||||
ifc.run("spatial.assign_container", products=["element"], relating_structure="container").should_be_called()
|
||||
ifc.run("aggregate.unassign_object", product="element").should_be_called().will_return("rel")
|
||||
collector.assign("relating_obj").should_be_called()
|
||||
collector.assign("related_obj").should_be_called()
|
||||
|
||||
@@ -52,7 +52,7 @@ class TestUnassignObject:
|
||||
def test_run(self, ifc, nest, collector):
|
||||
ifc.get_entity("related_obj").should_be_called().will_return("element")
|
||||
nest.get_container("element").should_be_called().will_return("container")
|
||||
ifc.run("spatial.assign_container", product="element", relating_structure="container").should_be_called()
|
||||
ifc.run("spatial.assign_container", products=["element"], relating_structure="container").should_be_called()
|
||||
ifc.run("nest.unassign_object", related_object="element").should_be_called().will_return("rel")
|
||||
collector.assign("relating_obj").should_be_called()
|
||||
collector.assign("related_obj").should_be_called()
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestAssignContainer:
|
||||
ifc.get_entity("structure_obj").should_be_called().will_return("structure")
|
||||
ifc.get_entity("element_obj").should_be_called().will_return("element")
|
||||
ifc.run(
|
||||
"spatial.assign_container", product="element", relating_structure="structure"
|
||||
"spatial.assign_container", products=["element"], relating_structure="structure"
|
||||
).should_be_called().will_return("rel")
|
||||
spatial.disable_editing("element_obj").should_be_called()
|
||||
collector.assign("element_obj").should_be_called()
|
||||
|
||||
@@ -125,5 +125,5 @@ class TestGetContainer(NewFile):
|
||||
tool.Ifc.set(ifc)
|
||||
element = ifc.createIfcWall()
|
||||
container = ifc.createIfcBuildingStorey()
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, product=element, relating_structure=container)
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, products=[element], relating_structure=container)
|
||||
assert subject.get_container(element) == container
|
||||
|
||||
@@ -41,7 +41,7 @@ class TestAssign(NewFile):
|
||||
ifcopenshell.api.run(
|
||||
"spatial.assign_container",
|
||||
tool.Ifc.get(),
|
||||
product=wall_element,
|
||||
products=[wall_element],
|
||||
relating_structure=tool.Ifc.get().by_type("IfcSite")[0],
|
||||
)
|
||||
subject.assign(wall_obj)
|
||||
@@ -196,7 +196,7 @@ class TestAssign(NewFile):
|
||||
ifcopenshell.api.run(
|
||||
"spatial.assign_container",
|
||||
tool.Ifc.get(),
|
||||
product=element,
|
||||
products=[element],
|
||||
relating_structure=tool.Ifc.get().by_type("IfcSite")[0],
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
@@ -236,7 +236,7 @@ class TestAssign(NewFile):
|
||||
ifcopenshell.api.run(
|
||||
"spatial.assign_container",
|
||||
tool.Ifc.get(),
|
||||
product=element,
|
||||
products=[element],
|
||||
relating_structure=tool.Ifc.get().by_type("IfcSite")[0],
|
||||
)
|
||||
bpy.context.scene.collection.objects.link(element_obj)
|
||||
@@ -255,7 +255,7 @@ class TestAssign(NewFile):
|
||||
ifcopenshell.api.run(
|
||||
"spatial.assign_container",
|
||||
tool.Ifc.get(),
|
||||
product=element,
|
||||
products=[element],
|
||||
relating_structure=tool.Ifc.get().by_type("IfcSite")[0],
|
||||
)
|
||||
bpy.context.scene.collection.objects.link(element_obj)
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestGetObjectStorey(test.bim.bootstrap.NewFile):
|
||||
wall = ifc.createIfcWall()
|
||||
tool.Ifc.link(wall, obj)
|
||||
storey = ifc.createIfcBuildingStorey()
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, product=wall, relating_structure=storey)
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, products=[wall], relating_structure=storey)
|
||||
assert subject.get_object_storey(obj) == storey
|
||||
|
||||
def test_only_returning_a_building_storey(self):
|
||||
@@ -50,7 +50,7 @@ class TestGetObjectStorey(test.bim.bootstrap.NewFile):
|
||||
wall = ifc.createIfcWall()
|
||||
tool.Ifc.link(wall, obj)
|
||||
building = ifc.createIfcBuilding()
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, product=wall, relating_structure=building)
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, products=[wall], relating_structure=building)
|
||||
assert subject.get_object_storey(obj) is None
|
||||
|
||||
def test_returning_nothing_if_uncontained(self):
|
||||
|
||||
@@ -70,5 +70,5 @@ class TestGetContainer(NewFile):
|
||||
tool.Ifc.set(ifc)
|
||||
element = ifc.createIfcWall()
|
||||
container = ifc.createIfcBuildingStorey()
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, product=element, relating_structure=container)
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, products=[element], relating_structure=container)
|
||||
assert subject.get_container(element) == container
|
||||
|
||||
@@ -154,7 +154,7 @@ class TestGetContainer(NewFile):
|
||||
ifc = ifcopenshell.file()
|
||||
site = ifc.createIfcSite()
|
||||
wall = ifc.createIfcWall()
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, product=wall, relating_structure=site)
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, products=[wall], relating_structure=site)
|
||||
assert subject.get_container(wall) == site
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ class TestGetDecomposedElements(NewFile):
|
||||
ifc = ifcopenshell.file()
|
||||
site = ifc.createIfcSite()
|
||||
wall = ifc.createIfcWall()
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, product=wall, relating_structure=site)
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, products=[wall], relating_structure=site)
|
||||
assert subject.get_decomposed_elements(site) == [wall]
|
||||
|
||||
|
||||
@@ -268,4 +268,4 @@ class TestSelectProducts(NewFile):
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
tool.Ifc.link(product, obj)
|
||||
subject.select_products([product])
|
||||
assert obj in bpy.context.selected_objects
|
||||
assert obj in bpy.context.selected_objects
|
||||
|
||||
Reference in New Issue
Block a user