mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
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:
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -280,11 +280,20 @@ prefix_symbols = {
|
||||
}
|
||||
|
||||
unit_symbols = {
|
||||
# si units
|
||||
"CUBIC_METRE": "m3",
|
||||
"GRAM": "g",
|
||||
"SECOND": "s",
|
||||
"SQUARE_METRE": "m2",
|
||||
"METRE": "m",
|
||||
# non si units
|
||||
"cubic inch": "in3",
|
||||
"cubic foot": "ft3",
|
||||
"cubic yard": "yd3",
|
||||
"square inch": "in2",
|
||||
"square foot": "ft2",
|
||||
"square yard": "yd2",
|
||||
"square mile": "mi2",
|
||||
}
|
||||
|
||||
|
||||
@@ -442,12 +451,11 @@ def get_symbol_quantity_class(symbol):
|
||||
|
||||
|
||||
def get_unit_symbol(unit):
|
||||
symbol = ""
|
||||
if unit.is_a("IfcSIUnit"):
|
||||
symbol = ""
|
||||
symbol += prefix_symbols.get(unit.Prefix, "")
|
||||
symbol += unit_symbols.get(unit.Name.replace("METER", "METRE"), "?")
|
||||
return symbol
|
||||
return "?"
|
||||
symbol += unit_symbols.get(unit.Name.replace("METER", "METRE"), "?")
|
||||
return symbol
|
||||
|
||||
|
||||
def convert_unit(value, from_unit, to_unit):
|
||||
|
||||
Reference in New Issue
Block a user