Display units for more pset/qset props #3235

Now current project units displayed for area and volume properties too.
https://i.imgur.com/7dgl1pC.png
Also added support for imperial units symbols.
This commit is contained in:
Andrej730
2023-06-05 14:54:41 +05:00
parent 0874320935
commit 2db82371bd
4 changed files with 30 additions and 6 deletions
@@ -144,8 +144,12 @@ class EnablePsetEditing(bpy.types.Operator):
if prop_template.PrimaryMeasureType in (
"IfcPositiveLengthMeasure",
"IfcLengthMeasure",
) or prop_template.TemplateType in ("Q_LENGTH",):
) or prop_template.TemplateType == "Q_LENGTH":
special_type = "LENGTH"
elif prop_template.PrimaryMeasureType == "IfcAreaMeasure" or prop_template.TemplateType == "Q_AREA":
special_type = "AREA"
elif prop_template.PrimaryMeasureType == "IfcVolumeMeasure" or prop_template.TemplateType == "Q_VOLUME":
special_type = "VOLUME"
metadata.special_type = special_type
if metadata.data_type == "string":
@@ -49,7 +49,7 @@ def draw_single_property(prop, layout, copy_operator=None):
layout.prop(
prop.metadata,
value_name,
text=prop.metadata.name,
text=prop.metadata.display_name,
)
if prop.metadata.is_uri:
op = layout.operator("bim.select_uri_attribute", text="", icon="FILE_FOLDER")
+12
View File
@@ -233,9 +233,21 @@ def set_lenght_value(self, value):
self.float_value = value / si_conversion
def get_display_name(self):
name = self.name
if not self.special_type or self.special_type == "LENGTH":
return name
unit_type = f"{self.special_type}UNIT"
project_unit = ifcopenshell.util.unit.get_project_unit(tool.Ifc.get(), unit_type)
unit_symbol = ifcopenshell.util.unit.get_unit_symbol(project_unit)
return f"{name}, {unit_symbol}"
class Attribute(PropertyGroup):
tooltip = "`Right Click > IFC Description` to read the attribute description and online documentation"
name: StringProperty(name="Name")
display_name: StringProperty(name="Display Name", get=get_display_name)
description: StringProperty(name="Description")
ifc_class: StringProperty(name="Ifc Class")
data_type: StringProperty(name="Data Type")