Module Contents#

class ifcopenshell.api.unit.assign_unit.Usecase(file, units=None, length=None, area=None, volume=None)#

Assign default project units

Whenever a unitised quantity is specified, such as a length, area, voltage, pressure, etc, these project units are used by default.

It is also possible to override units for specific properties. For example, generally you might want square metres for area measurements, but you might want square millimeters for the measurements of the cross sectional area of cables in cable trays. However, this function only deals with the default project units.


units (list[ifcopenshell.entity_instance.entity_instance],optional) – A list of units to assign as project defaults. See ifcopenshell.api.unit.add_si_unit, unit.add_conversion_based_unit, and unit.add_monetary_unit for information on how to create units.


The IfcUnitAssignment element

Return type



# 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])

# 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)
assign_units(self, unit_assignment, new_units)#
create_imperial_unit(self, unit_type, data)#
create_metric_unit(self, unit_type, data)#