Ideally it would be wonderful if there is some sort of helper library that based on the value type (e.g. IfcLengthMeasure and the project units) finds the appropriate unit and does the conversion. Indeed. However, due to the hierarchical nature of IFC, we will have to keep track of the relevant units context to provide support for proper UoM (Unit of Measurement) parsing. In the IfcProject context, we have to find the unit with UnitType == 'LENGTHUNIT'. In case we can't find it, then we have to look...
Ideally it would be wonderful if there is some sort of helper library that based on the value type (e.g. IfcLengthMeasure and the project units) finds the appropriate unit and does the conversion. Indeed. However, due to the hierarchical nature of IFC, we will have to keep track of the relevant units context to provide support for proper UoM (Unit of Measurement) parsing. In the IfcProject context, we have to find the unit with UnitType == 'LENGTHUNIT'. In case we can't find it, then we have to look...
Ideally it would be wonderful if there is some sort of helper library that based on the value type (e.g. IfcLengthMeasure and the project units) finds the appropriate unit and does the conversion. Indeed. However, due to the hierarchical nature of IFC, we will have to keep track of the relevant units context to provide support for proper UoM (Unit of Measurement) parsing. In the IfcProject context, we have to find the unit with UnitType == 'LENGTHUNIT'. In case we can't find it, then we have to look...
Answering my own question. It's all about identifying the LENGTHUNIT definition that applies in the current context. In the IfcProject context, we have to find the unit with UnitType == 'LENGTHUNIT'. In case we can't find it, then we have to look at the global IfcUnitAssignment level: import ifcopenshell ifc_file = ifcopenshell.open("/PATH/TO/IFCFILE.ifc") global_unit_assignments = ifc_file.by_type("IfcUnitAssignment") # The global context defines 0 or more unit sets, each containing IFC unit definitions...
I know how to query parameter values on objects, but I can't figure out how to determine their dimensional unit. Consider for instance the following definition: #1234=IfcPropertySingleValue('Maximum Ridge Height',$,IfcLengthMeasure(12.34),$) I know that the units are defined in the IfcProject object: project = ifc_file.by_type("IfcProject")[0] units = project.UnitsInContext.Units How can I determine whether 12.34 refers to mm, m or any other length unit?
I know how to query parameter values on objects, but I can't figure out how to determine their dimensional unit. Consider for instance the following definition: #1234=IfcPropertySingleValue('Maximum Ridge Height',$,IfcLengthMeasure(12.34),$) I know that the units are defined in the IfcProject object: project = ifc_file.by_type("IfcProject")[0] units = project.UnitsInContext.Units How can I determine whether 12.34 refers to mm, m or any other length unit?