Replace all ifcopenshell.api.run with ifcopenshell.api static functions.

This commit is contained in:
Dion Moult
2024-06-28 12:36:31 +10:00
parent b5d613989e
commit 07060fc769
432 changed files with 4633 additions and 4856 deletions
@@ -17,48 +17,51 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.pset
import ifcopenshell.api.root
import ifcopenshell.api.profile
import ifcopenshell.api.material
import ifcopenshell.util.element
class TestAddPset(test.bootstrap.IFC4):
def test_adding_a_pset_to_an_object(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
assert pset.is_a("IfcPropertySet")
assert "Pset_WallCommon" in ifcopenshell.util.element.get_psets(element)
def test_adding_a_pset_to_a_type_object(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
assert pset.is_a("IfcPropertySet")
assert "Pset_WallCommon" in ifcopenshell.util.element.get_psets(element)
def test_adding_a_pset_to_a_material(self):
material = ifcopenshell.api.run("material.add_material", self.file)
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Pset_MaterialCommon")
material = ifcopenshell.api.material.add_material(self.file)
pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="Pset_MaterialCommon")
assert pset.is_a("IfcMaterialProperties")
assert pset.Name == "Pset_MaterialCommon"
assert pset.Material == material
def test_adding_a_pset_to_a_profile(self):
profile = ifcopenshell.api.run("profile.add_parameterized_profile", self.file, ifc_class="IfcCircleProfileDef")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=profile, name="Pset_ProfileMechanical")
profile = ifcopenshell.api.profile.add_parameterized_profile(self.file, ifc_class="IfcCircleProfileDef")
pset = ifcopenshell.api.pset.add_pset(self.file, product=profile, name="Pset_ProfileMechanical")
assert pset.is_a("IfcProfileProperties")
if self.file.schema != "IFC2X3":
assert pset.Name == "Pset_ProfileMechanical"
assert pset.ProfileDefinition == profile
def test_adding_a_pset_to_a_context(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Custom_Pset")
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Custom_Pset")
assert pset.is_a("IfcPropertySet")
assert "Custom_Pset" in ifcopenshell.util.element.get_psets(element)
class TestAddPsetIFC2X3(test.bootstrap.IFC2X3, TestAddPset):
def test_adding_a_pset_to_a_project(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Custom_Pset")
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Custom_Pset")
assert pset.is_a("IfcPropertySet")
assert "Custom_Pset" in ifcopenshell.util.element.get_psets(element)