From aefcedf75450f793fbcf5ccc74d1b4765c1d482b Mon Sep 17 00:00:00 2001 From: Massimo Fabbro Date: Sun, 27 Aug 2023 23:07:48 +0200 Subject: [PATCH] Add model test about manual booleans --- src/blenderbim/test/tool/test_model.py | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/blenderbim/test/tool/test_model.py b/src/blenderbim/test/tool/test_model.py index 68c91a142e..90546c0a16 100644 --- a/src/blenderbim/test/tool/test_model.py +++ b/src/blenderbim/test/tool/test_model.py @@ -20,6 +20,7 @@ import bpy import ifcopenshell import blenderbim.core.tool import blenderbim.tool as tool +import numpy as np from test.bim.bootstrap import NewFile from blenderbim.tool.model import Model as subject @@ -50,3 +51,31 @@ class TestGenerateOccurrenceName(NewFile): bpy.context.scene.BIMModelProperties.occurrence_name_style = "CUSTOM" bpy.context.scene.BIMModelProperties.occurrence_name_function = '"Foobar"' assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar" + +class TestGetManualBooleans(NewFile): + def test_run(self): + assert isinstance(subject(), blenderbim.core.tool.Model) + + def test_len_returned_boolean(self): + ifc = ifcopenshell.file() + tool.Ifc.set(ifc) + ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject") + length = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT") + ifcopenshell.api.run("unit.assign_unit", ifc, units=[length]) + ifcopenshell.api.run("unit.assign_unit", ifc) + element = ifc.createIfcColumn() + hea100 = ifc.create_entity( + "IfcIShapeProfileDef", ProfileName="HEA100", ProfileType="AREA", + OverallWidth=100, OverallDepth=96, WebThickness=5, FlangeThickness=8, FilletRadius=12, + ) + model3d = ifcopenshell.api.run("context.add_context", ifc, context_type="Model") + body = ifcopenshell.api.run("context.add_context", ifc,context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d) + representation = ifcopenshell.api.run("geometry.add_profile_representation", ifc, context=body, profile=hea100, depth=5) + ifcopenshell.api.run("geometry.assign_representation", ifc, product=element, representation=representation) + matrix = np.eye(4) + matrix = ifcopenshell.util.placement.rotation(45,"X") @ matrix + matrix[:,3][0:3] = (0, 0, 3) + matrix = matrix.tolist() + ifcopenshell.api.run("geometry.add_boolean", ifc, representation = representation, type = "IfcHalfSpaceSolid", matrix = matrix) + assert len(subject.get_manual_booleans(element)) == 1 +