mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 05:00:53 +00:00
Address PR feedback from #6719
This commit is contained in:
@@ -25,6 +25,7 @@ import ifcopenshell.util.schema
|
|||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
from bonsai.bim.module.drawing.helper import format_distance
|
from bonsai.bim.module.drawing.helper import format_distance
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
from natsort import natsorted
|
||||||
|
|
||||||
|
|
||||||
def refresh():
|
def refresh():
|
||||||
@@ -39,11 +40,11 @@ class MaterialsData:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load(cls):
|
def load(cls):
|
||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
cls.data["material_types"] = sorted(cls.material_types(), key=lambda x: x[1].lower())
|
cls.data["material_types"] = cls.material_types()
|
||||||
cls.data["total_materials"] = cls.total_materials()
|
cls.data["total_materials"] = cls.total_materials()
|
||||||
cls.data["profiles"] = sorted(cls.profiles(), key=lambda x: x[1].lower())
|
cls.data["profiles"] = cls.profiles()
|
||||||
cls.data["styles"] = sorted(cls.styles(), key=lambda x: x[1].lower())
|
cls.data["styles"] = cls.styles()
|
||||||
cls.data["contexts"] = sorted(cls.contexts(), key=lambda x: x[1].lower())
|
cls.data["contexts"] = cls.contexts()
|
||||||
cls.data["material_styles_data"] = cls.material_styles_data()
|
cls.data["material_styles_data"] = cls.material_styles_data()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -67,15 +68,16 @@ class MaterialsData:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def profiles(cls):
|
def profiles(cls):
|
||||||
return [
|
results = [
|
||||||
(str(p.id()), p.ProfileName or "Unnamed", "")
|
(str(p.id()), p.ProfileName or "Unnamed", "")
|
||||||
for p in tool.Ifc.get().by_type("IfcProfileDef")
|
for p in tool.Ifc.get().by_type("IfcProfileDef")
|
||||||
if p.ProfileName
|
if (profile_name := p.ProfileName) is not None
|
||||||
]
|
]
|
||||||
|
return natsorted(results, key=lambda i: i[1])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def contexts(cls):
|
def contexts(cls):
|
||||||
results = []
|
results: list[tuple[str, str, str]] = []
|
||||||
for element in tool.Ifc.get().by_type("IfcGeometricRepresentationContext", include_subtypes=False):
|
for element in tool.Ifc.get().by_type("IfcGeometricRepresentationContext", include_subtypes=False):
|
||||||
results.append((str(element.id()), element.ContextType or "Unnamed", ""))
|
results.append((str(element.id()), element.ContextType or "Unnamed", ""))
|
||||||
for element in tool.Ifc.get().by_type("IfcGeometricRepresentationSubContext", include_subtypes=False):
|
for element in tool.Ifc.get().by_type("IfcGeometricRepresentationSubContext", include_subtypes=False):
|
||||||
@@ -90,15 +92,16 @@ class MaterialsData:
|
|||||||
"",
|
"",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return results
|
return natsorted(results, key=lambda i: i[1])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def styles(cls) -> list[tuple[str, str, str]]:
|
def styles(cls) -> list[tuple[str, str, str]]:
|
||||||
return [
|
results = [
|
||||||
(str(s.id()), style_name or "Unnamed", "")
|
(str(s.id()), style_name or "Unnamed", "")
|
||||||
for s in tool.Ifc.get().by_type("IfcPresentationStyle")
|
for s in tool.Ifc.get().by_type("IfcPresentationStyle")
|
||||||
if (style_name := s.Name)
|
if (style_name := s.Name) is not None
|
||||||
]
|
]
|
||||||
|
return natsorted(results, key=lambda i: i[1])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def material_styles_data(cls) -> dict[int, list[dict[str, Any]]]:
|
def material_styles_data(cls) -> dict[int, list[dict[str, Any]]]:
|
||||||
|
|||||||
Reference in New Issue
Block a user