Count styles based on the current stype type #5462

Previously it was showing number of all IfcPresentationStyles
This commit is contained in:
Andrej730
2024-09-30 17:08:26 +05:00
parent 616a8882d9
commit 7133b01b76
2 changed files with 14 additions and 4 deletions
+11 -2
View File
@@ -68,8 +68,17 @@ class StylesData:
]
@classmethod
def total_styles(cls):
return len(tool.Ifc.get().by_type("IfcPresentationStyle"))
def total_styles(cls) -> dict[str, int]:
total: dict[str, int] = {}
ifc_file = tool.Ifc.get()
for decl in cls.get_presentation_style_declarations():
total[decl.name()] = len(ifc_file.by_type(decl.name()))
return total
@classmethod
def get_presentation_style_declarations(cls):
declaration = tool.Ifc.schema().declaration_by_name("IfcPresentationStyle")
return ifcopenshell.util.schema.get_subtypes(declaration)
class BlenderMaterialStyleData:
+3 -2
View File
@@ -46,9 +46,10 @@ class BIM_PT_styles(Panel):
if not self.props.is_editing:
row = self.layout.row(align=True)
row.label(text="{} Styles".format(StylesData.data["total_styles"]), icon="SHADING_RENDERED")
style_type = self.props.style_type
row.label(text="{} Styles".format(StylesData.data["total_styles"][style_type]), icon="SHADING_RENDERED")
bonsai.bim.helper.prop_with_search(row, self.props, "style_type", text="")
row.operator("bim.load_styles", text="", icon="IMPORT").style_type = self.props.style_type
row.operator("bim.load_styles", text="", icon="IMPORT").style_type = style_type
return
active_style = self.props.styles and self.props.active_style_index < len(self.props.styles)