Manual booleans are now tracked via a Pset instead of arbitrary class conventions which should fix a bunch of issues.

This commit is contained in:
Dion Moult
2023-10-10 17:33:00 +11:00
parent e4f5b0e3d8
commit 05f6f4efab
7 changed files with 93 additions and 45 deletions
@@ -47,13 +47,21 @@ class Usecase:
result = self.create_blender_mesh()
items = []
for item in self.settings["representation"].Items:
# For now, we don't use IfcBooleanClippingResult.
# This is unofficial but we assume that clipping results are part
# of automated clips, whereas IfcBooleanResults are manual bools.
# This is really terrible, but until we find a better solution...
items.append(self.file.createIfcBooleanResult(self.settings["operator"], item, result))
if (
self.settings["operator"] == "DIFFERENCE"
and result.is_a("IfcHalfSpaceSolid")
and (
item.is_a("IfcSweptAreaSolid")
or item.is_a("IfcSweptDiskSolid")
or item.is_a("IfcBooleanClippingResult")
)
):
items.append(self.file.createIfcBooleanClippingResult(self.settings["operator"], item, result))
else:
items.append(self.file.createIfcBooleanResult(self.settings["operator"], item, result))
self.settings["representation"].RepresentationType = "CSG"
self.settings["representation"].Items = items
return items
def create_half_space_solid(self):
clipping = np.array(self.settings["matrix"])[:3]
@@ -351,8 +351,8 @@ class TestSelector(test.bootstrap.IFC4):
pset_2 = ifcopenshell.api.run("pset.add_pset", self.file, product=element_2, name="Foo_Bar")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset_1, properties={"Foo": "Bar"})
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset_2, properties={"Foo": "BOO"})
assert subject.Selector.parse(self.file, '.IfcElement[Foo_Bar.Foo != "Bar"]') == [element_2]
assert subject.Selector.parse(self.file, '.IfcElement[Foo_Bar.Foo != "BOO"]') == [element_1]
assert subject.Selector.parse(self.file, '.IfcElement["Foo_Bar"."Foo" != "Bar"]') == [element_2]
assert subject.Selector.parse(self.file, '.IfcElement["Foo_Bar"."Foo" != "BOO"]') == [element_1]
def test_selecting_when_attribute_is_none(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")