ifcopenshell.util.unit#

Module Contents#

ifcopenshell.util.unit.imperial_types#
ifcopenshell.util.unit.named_dimensions#
ifcopenshell.util.unit.prefix_symbols#
ifcopenshell.util.unit.prefixes#
ifcopenshell.util.unit.si_conversions#
ifcopenshell.util.unit.si_dimensions#
ifcopenshell.util.unit.si_offsets#
ifcopenshell.util.unit.si_type_names#
ifcopenshell.util.unit.unit_names = ['AMPERE', 'BECQUEREL', 'CANDELA', 'COULOMB', 'CUBIC_METRE', 'DEGREE_CELSIUS', 'FARAD', 'GRAM',...#
ifcopenshell.util.unit.unit_symbols#
ifcopenshell.util.unit.calculate_unit_scale(ifc_file)#

Returns a unit scale factor to convert to and from IFC project length units and SI meters

Example:

ifc_project_length * unit_scale = si_meters
si_meters / unit_scale = ifc_project_length
Parameters

ifc_file (ifcopenshell.file.file) – The IFC file.

Returns

The scale factor

Return type

float

ifcopenshell.util.unit.convert(value, from_prefix, from_unit, to_prefix, to_unit)#

Converts between length, area, and volume units

In this case, you manually specify the names and (optionally) prefixes to convert to and from. In case you want to automatically convert to units already available as IFC entities, consider using convert_unit() instead.

Parameters
  • value (float) – The numeric value you want to convert

  • from_prefix (str,optional) – A prefix from IfcSIPrefix. Can be None.

  • from_unit (str) – IfcSIUnitName or IfcConversionBasedUnit.Name

  • to_prefix (str,optional) – A prefix from IfcSIPrefix. Can be None.

  • to_unit (str) – IfcSIUnitName or IfcConversionBasedUnit.Name

Returns

The converted value.

Return type

float

ifcopenshell.util.unit.convert_unit(value, from_unit, to_unit)#

Convert from one unit to another unit

Parameters
Returns

The converted value.

Return type

float

ifcopenshell.util.unit.format_length(value, precision, decimal_places=2, suppress_zero_inches=True, unit_system='imperial', input_unit='foot', output_unit='foot')#

Formats a length for readability and imperial formatting

Parameters
  • value (float) – The value in meters if metric, or either decimal feet or inches if imperial depending on input_unit.

  • precision (float) – How precise the format should be. I.e. round to nearest. For imperial, it is 1/Nth. E.g. 12 means to the nearest 1/12th of an inch.

  • decimal_places (int) – How many decimal places to display. Defaults to 2.

  • suppress_zero_inches (bool) – If imperial, whether or not to supress the inches if the inches is zero.

  • unit_system (str) – Choose whether your value is “metric” or “imperial”

  • input_unit (str) – If imperial, specify whether your value is “foot” or “inch”.

  • output_unit – If imperial, specify whether your value is “foot” to format as both feet and inches, or “inch” if only inches should be shown.

ifcopenshell.util.unit.get_measure_unit_type(measure_class)#
ifcopenshell.util.unit.get_named_dimensions(name)#
ifcopenshell.util.unit.get_prefix(text)#
ifcopenshell.util.unit.get_prefix_multiplier(text)#
ifcopenshell.util.unit.get_project_unit(ifc_file, unit_type)#

Get the default project unit of a particular unit type

Parameters
  • ifc_file (ifcopenshell.file.file) – The IFC file.

  • unit_type (str) – The type of unit, taken from the list of IFC unit types, such as “LENGTHUNIT”.

Returns

The IFC unit entity, or nothing if there is no default project unit defined.

Return type

ifcopenshell.entity_instance,None

ifcopenshell.util.unit.get_property_unit(prop, ifc_file)#
ifcopenshell.util.unit.get_si_dimensions(name)#
ifcopenshell.util.unit.get_symbol_measure_class(symbol)#
ifcopenshell.util.unit.get_symbol_quantity_class(symbol)#
ifcopenshell.util.unit.get_unit_assignment(ifc_file)#
ifcopenshell.util.unit.get_unit_measure_class(unit_type)#
ifcopenshell.util.unit.get_unit_name(text)#
ifcopenshell.util.unit.get_unit_symbol(unit)#