mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Generate functions for all API usecases for better static code features. See #2693.
This commit is contained in:
@@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user