Generate functions for all API usecases for better static code features. See #2693.

This commit is contained in:
Dion Moult
2024-05-06 14:35:39 +10:00
parent 10f894e2ea
commit d11ec67129
330 changed files with 13283 additions and 13751 deletions
@@ -17,32 +17,29 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
class Usecase:
def __init__(self, file, currency="DOLLARYDOO"):
"""Add a new currency
def add_monetary_unit(file, currency="DOLLARYDOO") -> None:
"""Add a new currency
Currency units are useful in cost plans to know in what currency the
costs are calculated in. The currencies should follow ISO 4217, like
USD, GBP, AUD, MYR, etc.
Currency units are useful in cost plans to know in what currency the
costs are calculated in. The currencies should follow ISO 4217, like
USD, GBP, AUD, MYR, etc.
:param currency: The currency code
:type currency: str
:return: The newly created IfcMonetaryUnit
:rtype: ifcopenshell.entity_instance
:param currency: The currency code
:type currency: str
:return: The newly created IfcMonetaryUnit
:rtype: ifcopenshell.entity_instance
Example:
Example:
.. code:: python
.. code:: python
# 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")
# 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")
# Make it our default currency
ifcopenshell.api.run("unit.assign_unit", model, units=[zwl])
"""
self.file = file
self.settings = {"currency": currency}
# Make it our default currency
ifcopenshell.api.run("unit.assign_unit", model, units=[zwl])
"""
settings = {"currency": currency}
def execute(self):
return self.file.create_entity("IfcMonetaryUnit", self.settings["currency"])
return file.create_entity("IfcMonetaryUnit", settings["currency"])