mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Write docs for unit API module
This commit is contained in:
@@ -18,11 +18,31 @@
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
def __init__(self, file, units=None):
|
||||
"""Unassigns units as default units for the project
|
||||
|
||||
:param units: A list of units to assign as project defaults.
|
||||
:type units: list[ifcopenshell.entity_instance.entity_instance],optional
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example::
|
||||
|
||||
# You need a project before you can assign units.
|
||||
ifcopenshell.api.run("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")
|
||||
|
||||
# Make it our default units, if we are doing a metric building
|
||||
ifcopenshell.api.run("unit.assign_unit", model, units=[length, area])
|
||||
|
||||
# Actually, we don't need areas.
|
||||
ifcopenshell.api.run("unit.unassign_unit", model, units=[area])
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"units": None}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
self.settings = {"units": units}
|
||||
|
||||
def execute(self):
|
||||
unit_assignment = self.file.by_type("IfcUnitAssignment")
|
||||
|
||||
Reference in New Issue
Block a user