mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-06 12:26:26 +00:00
aggregate.assign_object - support batching #4474
This commit is contained in:
@@ -473,7 +473,7 @@ class AssignStructuralLoadCase(bpy.types.Operator, tool.Ifc.Operator):
|
||||
self.file,
|
||||
**{
|
||||
"relating_object": self.file.by_id(self.work_plan),
|
||||
"product": self.file.by_id(self.load_case),
|
||||
"products": [self.file.by_id(self.load_case)],
|
||||
},
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -29,7 +29,7 @@ def assign_object(ifc, aggregator, collector, relating_obj=None, related_obj=Non
|
||||
if not aggregator.can_aggregate(relating_obj, related_obj):
|
||||
return
|
||||
rel = ifc.run(
|
||||
"aggregate.assign_object", product=ifc.get_entity(related_obj), relating_object=ifc.get_entity(relating_obj)
|
||||
"aggregate.assign_object", products=[ifc.get_entity(related_obj)], relating_object=ifc.get_entity(relating_obj)
|
||||
)
|
||||
collector.assign(relating_obj)
|
||||
collector.assign(related_obj)
|
||||
|
||||
@@ -61,7 +61,7 @@ def remove_work_schedule(ifc, work_schedule=None):
|
||||
|
||||
def assign_work_schedule(ifc, work_plan=None, work_schedule=None):
|
||||
if work_schedule:
|
||||
return ifc.run("aggregate.assign_object", relating_object=work_plan, product=work_schedule)
|
||||
return ifc.run("aggregate.assign_object", relating_object=work_plan, products=[work_schedule])
|
||||
|
||||
|
||||
def unassign_work_schedule(ifc, work_schedule=None):
|
||||
|
||||
@@ -127,9 +127,9 @@ class Obj2Ifc:
|
||||
self.storey = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcBuildingStorey", name="My Storey"
|
||||
)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, product=site, relating_object=project)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, product=building, relating_object=site)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, product=self.storey, relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[site], relating_object=project)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[building], relating_object=site)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[self.storey], relating_object=building)
|
||||
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=site)
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=building)
|
||||
|
||||
@@ -120,9 +120,9 @@ class Obj2Ifc:
|
||||
self.storey = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcBuildingStorey", name="My Storey"
|
||||
)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, product=site, relating_object=project)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, product=building, relating_object=site)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, product=self.storey, relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[site], relating_object=project)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[building], relating_object=site)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[self.storey], relating_object=building)
|
||||
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=site)
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=building)
|
||||
|
||||
@@ -38,7 +38,7 @@ class TestAssignObject:
|
||||
ifc.get_entity("relating_obj").should_be_called().will_return("relating_object")
|
||||
ifc.get_entity("related_obj").should_be_called().will_return("related_object")
|
||||
ifc.run(
|
||||
"aggregate.assign_object", product="related_object", relating_object="relating_object"
|
||||
"aggregate.assign_object", products=["related_object"], relating_object="relating_object"
|
||||
).should_be_called().will_return("rel")
|
||||
aggregate.disable_editing("related_obj").should_be_called()
|
||||
collector.assign("relating_obj").should_be_called()
|
||||
|
||||
@@ -320,8 +320,8 @@ class TestGetParentSpace(NewFile):
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcBuildingStorey")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcSpace")
|
||||
project = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subelement, relating_object=element)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=element, relating_object=project)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, products=[element], relating_object=project)
|
||||
assert subject.get_parent_space(subelement) == element
|
||||
assert subject.get_parent_space(element) is None
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class TestAssign(NewFile):
|
||||
"aggregate.assign_object",
|
||||
tool.Ifc.get(),
|
||||
relating_object=tool.Ifc.get().by_type("IfcSite")[0],
|
||||
product=space_element,
|
||||
products=[space_element],
|
||||
)
|
||||
subject.assign(space_obj)
|
||||
assert len(space_obj.users_collection) == 1
|
||||
@@ -84,7 +84,7 @@ class TestAssign(NewFile):
|
||||
"aggregate.assign_object",
|
||||
tool.Ifc.get(),
|
||||
relating_object=tool.Ifc.get().by_type("IfcSite")[0],
|
||||
product=space_element,
|
||||
products=[space_element],
|
||||
)
|
||||
subject.assign(space_obj)
|
||||
subject.assign(space_obj)
|
||||
@@ -103,7 +103,7 @@ class TestAssign(NewFile):
|
||||
"aggregate.assign_object",
|
||||
tool.Ifc.get(),
|
||||
relating_object=tool.Ifc.get().by_type("IfcSite")[0],
|
||||
product=space_element,
|
||||
products=[space_element],
|
||||
)
|
||||
subject.assign(space_obj)
|
||||
assert len(space_obj.users_collection) == 1
|
||||
@@ -121,7 +121,7 @@ class TestAssign(NewFile):
|
||||
"aggregate.assign_object",
|
||||
tool.Ifc.get(),
|
||||
relating_object=element,
|
||||
product=subelement,
|
||||
products=[subelement],
|
||||
)
|
||||
subject.assign(element_obj)
|
||||
assert len(element_obj.users_collection) == 1
|
||||
@@ -161,7 +161,7 @@ class TestAssign(NewFile):
|
||||
"aggregate.assign_object",
|
||||
tool.Ifc.get(),
|
||||
relating_object=tool.Ifc.get().by_type("IfcSite")[0],
|
||||
product=space_element,
|
||||
products=[space_element],
|
||||
)
|
||||
subject.assign(space_obj)
|
||||
assert bpy.context.scene.collection.children.find(space_collection.name) == -1
|
||||
@@ -180,7 +180,7 @@ class TestAssign(NewFile):
|
||||
"aggregate.assign_object",
|
||||
tool.Ifc.get(),
|
||||
relating_object=element,
|
||||
product=subelement,
|
||||
products=[subelement],
|
||||
)
|
||||
subject.assign(element_obj)
|
||||
subject.assign(subelement_obj)
|
||||
@@ -203,7 +203,7 @@ class TestAssign(NewFile):
|
||||
"aggregate.assign_object",
|
||||
tool.Ifc.get(),
|
||||
relating_object=element,
|
||||
product=subelement,
|
||||
products=[subelement],
|
||||
)
|
||||
subject.assign(subelement_obj)
|
||||
assert subelement_obj.users_collection[0].name == "IfcSite/My Site"
|
||||
|
||||
@@ -86,8 +86,8 @@ class TestGetStoreyHeight(test.bim.bootstrap.NewFile):
|
||||
storey.Elevation = 3000
|
||||
storey2 = ifc.createIfcBuildingStorey()
|
||||
storey2.Elevation = 5000
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=storey, relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=storey2, relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, products=[storey], relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, products=[storey2], relating_object=building)
|
||||
assert subject.get_storey_height_in_si(storey, 1) == 2.0
|
||||
|
||||
def test_getting_a_double_storey_height(self):
|
||||
@@ -103,9 +103,9 @@ class TestGetStoreyHeight(test.bim.bootstrap.NewFile):
|
||||
storey2.Elevation = 5000
|
||||
storey3 = ifc.createIfcBuildingStorey()
|
||||
storey3.Elevation = 9000
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=storey, relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=storey2, relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=storey3, relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, products=[storey], relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, products=[storey2], relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, products=[storey3], relating_object=building)
|
||||
assert subject.get_storey_height_in_si(storey, 2) == 6.0
|
||||
|
||||
def test_only_considering_storeys_in_the_same_building(self):
|
||||
@@ -116,7 +116,7 @@ class TestGetStoreyHeight(test.bim.bootstrap.NewFile):
|
||||
storey.Elevation = 3000
|
||||
storey2 = ifc.createIfcBuildingStorey()
|
||||
storey2.Elevation = 5000
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=storey, relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, products=[storey], relating_object=building)
|
||||
assert subject.get_storey_height_in_si(storey, 1) is None
|
||||
|
||||
def test_returning_none_if_the_storey_height_is_undefined(self):
|
||||
@@ -124,7 +124,7 @@ class TestGetStoreyHeight(test.bim.bootstrap.NewFile):
|
||||
tool.Ifc.set(ifc)
|
||||
building = ifc.createIfcBuilding()
|
||||
storey = ifc.createIfcBuildingStorey()
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=storey, relating_object=building)
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, products=[storey], relating_object=building)
|
||||
assert subject.get_storey_height_in_si(storey, 1) is None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user