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
@@ -16,26 +16,25 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import pytest
import test.bootstrap
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.root
import ifcopenshell.api.style
import ifcopenshell.api.material
class TestUnassignMaterialStyleIFC2X3(test.bootstrap.IFC2X3):
def test_run(self):
material = ifcopenshell.api.run("material.add_material", self.file)
material = ifcopenshell.api.material.add_material(self.file)
context = self.file.createIfcGeometricRepresentationContext()
style = self.file.createIfcSurfaceStyle()
ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
# unassign 1 style
style2 = self.file.createIfcSurfaceStyle()
item = self.file.by_type("IfcStyledItem")[0]
item.Styles = item.Styles + (style2,)
ifcopenshell.api.run(
"style.unassign_material_style", self.file, material=material, style=style2, context=context
)
ifcopenshell.api.style.unassign_material_style(self.file, material=material, style=style2, context=context)
if self.file.schema != "IFC2X3":
assert item.Styles == (style,)
else:
@@ -44,9 +43,7 @@ class TestUnassignMaterialStyleIFC2X3(test.bootstrap.IFC2X3):
assert item.Styles[0].Styles == (style,)
# unassign last style
ifcopenshell.api.run(
"style.unassign_material_style", self.file, material=material, style=style, context=context
)
ifcopenshell.api.style.unassign_material_style(self.file, material=material, style=style, context=context)
assert len(self.file.by_type("IfcMaterialDefinitionRepresentation")) == 0
assert len(self.file.by_type("IfcStyledRepresentation")) == 0
assert len(self.file.by_type("IfcStyledItem")) == 0
@@ -57,7 +54,7 @@ class TestUnassignMaterialStyleIFC4(test.bootstrap.IFC4, TestUnassignMaterialSty
def test_update_shape_aspect_representaitons_items_styles_if_material_is_part_of_matching_material_constituents(
self,
):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
name = "Concrete"
product_shape = self.file.createIfcProductDefinitionShape()
element.Representation = product_shape
@@ -71,19 +68,15 @@ class TestUnassignMaterialStyleIFC4(test.bootstrap.IFC4, TestUnassignMaterialSty
shape_aspect.PartOfProductDefinitionShape = product_shape
style = self.file.createIfcSurfaceStyle()
material = ifcopenshell.api.run("material.add_material", self.file)
material_set = ifcopenshell.api.run(
"material.add_material_set", self.file, set_type="IfcMaterialConstituentSet"
)
constituent = ifcopenshell.api.run(
"material.add_constituent", self.file, constituent_set=material_set, material=material
material = ifcopenshell.api.material.add_material(self.file)
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
constituent = ifcopenshell.api.material.add_constituent(
self.file, constituent_set=material_set, material=material
)
constituent.Name = name
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
ifcopenshell.api.run(
"style.unassign_material_style", self.file, material=material, style=style, context=context
)
ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
ifcopenshell.api.style.unassign_material_style(self.file, material=material, style=style, context=context)
assert len(item.StyledByItem) == 0