mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 22:31:55 +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 (
|
if prop_template.PrimaryMeasureType in (
|
||||||
"IfcPositiveLengthMeasure",
|
"IfcPositiveLengthMeasure",
|
||||||
"IfcLengthMeasure",
|
"IfcLengthMeasure",
|
||||||
) or prop_template.TemplateType in ("Q_LENGTH",):
|
) or prop_template.TemplateType == "Q_LENGTH":
|
||||||
special_type = "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
|
metadata.special_type = special_type
|
||||||
|
|
||||||
if metadata.data_type == "string":
|
if metadata.data_type == "string":
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ def draw_single_property(prop, layout, copy_operator=None):
|
|||||||
layout.prop(
|
layout.prop(
|
||||||
prop.metadata,
|
prop.metadata,
|
||||||
value_name,
|
value_name,
|
||||||
text=prop.metadata.name,
|
text=prop.metadata.display_name,
|
||||||
)
|
)
|
||||||
if prop.metadata.is_uri:
|
if prop.metadata.is_uri:
|
||||||
op = layout.operator("bim.select_uri_attribute", text="", icon="FILE_FOLDER")
|
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
|
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):
|
class Attribute(PropertyGroup):
|
||||||
tooltip = "`Right Click > IFC Description` to read the attribute description and online documentation"
|
tooltip = "`Right Click > IFC Description` to read the attribute description and online documentation"
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
|
display_name: StringProperty(name="Display Name", get=get_display_name)
|
||||||
description: StringProperty(name="Description")
|
description: StringProperty(name="Description")
|
||||||
ifc_class: StringProperty(name="Ifc Class")
|
ifc_class: StringProperty(name="Ifc Class")
|
||||||
data_type: StringProperty(name="Data Type")
|
data_type: StringProperty(name="Data Type")
|
||||||
|
|||||||
@@ -280,11 +280,20 @@ prefix_symbols = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unit_symbols = {
|
unit_symbols = {
|
||||||
|
# si units
|
||||||
"CUBIC_METRE": "m3",
|
"CUBIC_METRE": "m3",
|
||||||
"GRAM": "g",
|
"GRAM": "g",
|
||||||
"SECOND": "s",
|
"SECOND": "s",
|
||||||
"SQUARE_METRE": "m2",
|
"SQUARE_METRE": "m2",
|
||||||
"METRE": "m",
|
"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):
|
def get_unit_symbol(unit):
|
||||||
|
symbol = ""
|
||||||
if unit.is_a("IfcSIUnit"):
|
if unit.is_a("IfcSIUnit"):
|
||||||
symbol = ""
|
|
||||||
symbol += prefix_symbols.get(unit.Prefix, "")
|
symbol += prefix_symbols.get(unit.Prefix, "")
|
||||||
symbol += unit_symbols.get(unit.Name.replace("METER", "METRE"), "?")
|
symbol += unit_symbols.get(unit.Name.replace("METER", "METRE"), "?")
|
||||||
return symbol
|
return symbol
|
||||||
return "?"
|
|
||||||
|
|
||||||
|
|
||||||
def convert_unit(value, from_unit, to_unit):
|
def convert_unit(value, from_unit, to_unit):
|
||||||
|
|||||||
Reference in New Issue
Block a user