Write docs for unit API module

This commit is contained in:
Dion Moult
2023-01-04 16:09:39 +11:00
parent 90d4d5afda
commit fd8774718e
10 changed files with 272 additions and 40 deletions
@@ -18,11 +18,40 @@
class Usecase:
def __init__(self, file, **settings):
def __init__(self, file, unit_type="USERDEFINED", name="THINGAMAJIG", dimensions=None):
"""Add a new arbitrary unit that can only be interpreted in a project specific context
Occasionally the construction industry uses arbitrary units to quantify
objects, like "pairs" of door hardware, "palettes" or "boxes" of fixings
or equipment.
:param unit_type: Typically should be left as USERDEFINED, unless for
some bizarre reason you are redefining something you could use a
sensible normal unit for. In that case, firstly stop whatever you're
doing and have a hard think about your life, and then if life really
is going that badly for you, check out the IFC docs for IfcUnitEnum.
:type unit_type: str
:param name: Give your unit a name. X what? X bananas?
:type name: str
:param dimensions: Units typically measure one of 7 fundamental physical
dimensions: length, mass, time, electric current, temperature,
substance amount, or luminous intensity. These are represented as a
list of 7 integers, representing the exponents of each one of these
dimensions. For example, a length unit is (1, 0, 0, 0, 0, 0, 0),
where as an area unit is (2, 0, 0, 0, 0, 0, 0). A unit of meters per
second is (1, 0, -1, 0, 0, 0, 0). For context dependent units, it is
recommended to leave this as the default of (0, 0, 0, 0, 0, 0, 0).
:type dimensions: list[int]
:return: The new IfcContextDependentUnit
:rtype: ifcopenshell.entity_instance.entity_instance
Example::
# Boxes of things
ifcopenshell.api.run("unit.add_context_dependent_unit", model, name="BOXES")
"""
self.file = file
self.settings = {"unit_type": "USERDEFINED", "name": "THINGAMAJIG", "dimensions": (0, 0, 0, 0, 0, 0, 0)}
for key, value in settings.items():
self.settings[key] = value
self.settings = {"unit_type": unit_type, "name": name, "dimensions": dimensions or (0, 0, 0, 0, 0, 0, 0)}
def execute(self):
return self.file.create_entity(