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
@@ -55,7 +55,7 @@ def add_context_dependent_unit(
.. code:: python
# Boxes of things
ifcopenshell.api.run("unit.add_context_dependent_unit", model, name="BOXES")
ifcopenshell.api.unit.add_context_dependent_unit(model, name="BOXES")
"""
settings = {"unit_type": unit_type, "name": name, "dimensions": dimensions}
@@ -53,11 +53,11 @@ def add_conversion_based_unit(
.. code:: python
# Some common imperial measurements
length = ifcopenshell.api.run("unit.add_conversion_based_unit", model, name="inch")
area = ifcopenshell.api.run("unit.add_conversion_based_unit", model, name="square foot")
length = ifcopenshell.api.unit.add_conversion_based_unit(model, name="inch")
area = ifcopenshell.api.unit.add_conversion_based_unit(model, name="square foot")
# Make it our default units, if we are doing an imperial building
ifcopenshell.api.run("unit.assign_unit", model, units=[length, area])
ifcopenshell.api.unit.assign_unit(model, units=[length, area])
"""
settings = {"name": name, "conversion_offset": conversion_offset}
@@ -36,10 +36,10 @@ def add_monetary_unit(file: ifcopenshell.file, currency: str = "DOLLARYDOO") ->
# If you do all your cost plans in Zimbabwean dollars then nobody
# knows how accurate the numbers are.
zwl = ifcopenshell.api.run("unit.add_monetary_unit", model, currency="ZWL")
zwl = ifcopenshell.api.unit.add_monetary_unit(model, currency="ZWL")
# Make it our default currency
ifcopenshell.api.run("unit.assign_unit", model, units=[zwl])
ifcopenshell.api.unit.assign_unit(model, units=[zwl])
"""
settings = {"currency": currency}
@@ -52,11 +52,11 @@ def add_si_unit(
.. code:: python
# Millimeters and square meters
length = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="LENGTHUNIT", prefix="MILLI")
area = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="AREAUNIT")
length = ifcopenshell.api.unit.add_si_unit(model, unit_type="LENGTHUNIT", prefix="MILLI")
area = ifcopenshell.api.unit.add_si_unit(model, unit_type="AREAUNIT")
# Make it our default units, if we are doing a metric building
ifcopenshell.api.run("unit.assign_unit", model, units=[length, area])
ifcopenshell.api.unit.assign_unit(model, units=[length, area])
"""
settings = {"unit_type": unit_type, "prefix": prefix}
@@ -51,20 +51,20 @@ def assign_unit(
.. code:: python
# You need a project before you can assign units.
ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
# Millimeters and square meters
length = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="LENGTHUNIT", prefix="MILLI")
area = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="AREAUNIT")
length = ifcopenshell.api.unit.add_si_unit(model, unit_type="LENGTHUNIT", prefix="MILLI")
area = ifcopenshell.api.unit.add_si_unit(model, unit_type="AREAUNIT")
# Make it our default units, if we are doing a metric building
ifcopenshell.api.run("unit.assign_unit", model, units=[length, area])
ifcopenshell.api.unit.assign_unit(model, units=[length, area])
# Alternatively, you may specify without any arguments to
# automatically create millimeters, square meters, and cubic meters
# as a convenience for testing purposes. Sorry imperial folks, we
# prioritise metric here.
ifcopenshell.api.run("unit.assign_unit", model)
ifcopenshell.api.unit.assign_unit(model)
"""
usecase = Usecase()
usecase.file = file
@@ -38,10 +38,10 @@ def edit_monetary_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instan
# If you do all your cost plans in Zimbabwean dollars then nobody
# knows how accurate the numbers are.
zwl = ifcopenshell.api.run("unit.add_monetary_unit", model, currency="ZWL")
zwl = ifcopenshell.api.unit.add_monetary_unit(model, currency="ZWL")
# Ah who are we kidding
ifcopenshell.api.run("unit.edit_monetary_unit", model, unit=zwl, attributes={"Currency": "USD"})
ifcopenshell.api.unit.edit_monetary_unit(model, unit=zwl, attributes={"Currency": "USD"})
"""
settings = {"unit": unit, "attributes": attributes or {}}
@@ -40,10 +40,10 @@ def edit_named_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance,
.. code:: python
# Boxes of things
unit = ifcopenshell.api.run("unit.add_context_dependent_unit", model, name="BOXES")
unit = ifcopenshell.api.unit.add_context_dependent_unit(model, name="BOXES")
# Uh, crates? Boxes? Whatever.
ifcopenshell.api.run("unit.edit_named_unit", model, unit=unit, attibutes={"Name": "CRATES"})
ifcopenshell.api.unit.edit_named_unit(model, unit=unit, attibutes={"Name": "CRATES"})
"""
settings = {"unit": unit, "attributes": attributes or {}}
@@ -36,10 +36,10 @@ def remove_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance) ->
.. code:: python
# What?
unit = ifcopenshell.api.run("unit.add_context_dependent_unit", model, name="HANDFULS")
unit = ifcopenshell.api.unit.add_context_dependent_unit(model, name="HANDFULS")
# Yeah maybe not.
ifcopenshell.api.run("unit.remove_unit", model, unit=unit)
ifcopenshell.api.unit.remove_unit(model, unit=unit)
"""
settings = {"unit": unit}
@@ -32,17 +32,17 @@ def unassign_unit(file: ifcopenshell.file, units: Optional[list[ifcopenshell.ent
.. code:: python
# You need a project before you can assign units.
ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
# Millimeters and square meters
length = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="LENGTHUNIT", prefix="MILLI")
area = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="AREAUNIT")
length = ifcopenshell.api.unit.add_si_unit(model, unit_type="LENGTHUNIT", prefix="MILLI")
area = ifcopenshell.api.unit.add_si_unit(model, unit_type="AREAUNIT")
# Make it our default units, if we are doing a metric building
ifcopenshell.api.run("unit.assign_unit", model, units=[length, area])
ifcopenshell.api.unit.assign_unit(model, units=[length, area])
# Actually, we don't need areas.
ifcopenshell.api.run("unit.unassign_unit", model, units=[area])
ifcopenshell.api.unit.unassign_unit(model, units=[area])
"""
settings = {"units": units}