mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Show length, area, volume units by default in unit panel for convenience
This commit is contained in:
@@ -35,6 +35,9 @@ class UnitsData:
|
||||
@classmethod
|
||||
def load(cls):
|
||||
cls.data = {
|
||||
"length_unit": cls.length_unit(),
|
||||
"area_unit": cls.area_unit(),
|
||||
"volume_unit": cls.volume_unit(),
|
||||
"unit_classes": cls.unit_classes(),
|
||||
"named_unit_types": cls.named_unit_types(),
|
||||
"conversion_unit_types": cls.conversion_unit_types(),
|
||||
@@ -42,6 +45,21 @@ class UnitsData:
|
||||
}
|
||||
cls.is_loaded = True
|
||||
|
||||
@classmethod
|
||||
def length_unit(cls):
|
||||
if unit := ifcopenshell.util.unit.get_project_unit(tool.Ifc.get(), "LENGTHUNIT"):
|
||||
return ifcopenshell.util.unit.get_full_unit_name(unit)
|
||||
|
||||
@classmethod
|
||||
def area_unit(cls):
|
||||
if unit := ifcopenshell.util.unit.get_project_unit(tool.Ifc.get(), "AREAUNIT"):
|
||||
return ifcopenshell.util.unit.get_full_unit_name(unit)
|
||||
|
||||
@classmethod
|
||||
def volume_unit(cls):
|
||||
if unit := ifcopenshell.util.unit.get_project_unit(tool.Ifc.get(), "VOLUMEUNIT"):
|
||||
return ifcopenshell.util.unit.get_full_unit_name(unit)
|
||||
|
||||
@classmethod
|
||||
def unit_classes(cls):
|
||||
declarations = ifcopenshell.util.schema.get_subtypes(tool.Ifc.schema().declaration_by_name("IfcNamedUnit"))
|
||||
|
||||
@@ -51,6 +51,17 @@ class BIM_PT_units(Panel):
|
||||
row.operator("bim.load_units", text="", icon="GREASEPENCIL")
|
||||
|
||||
if not self.props.is_editing:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="Length Unit", icon="ARROW_LEFTRIGHT")
|
||||
row.label(text=str(UnitsData.data["length_unit"]))
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="Area Unit", icon="ORIENTATION_VIEW")
|
||||
row.label(text=str(UnitsData.data["area_unit"]))
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="Volume Unit", icon="EMPTY_ARROWS")
|
||||
row.label(text=str(UnitsData.data["volume_unit"]))
|
||||
return
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
|
||||
Reference in New Issue
Block a user