mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Count styles based on the current stype type #5462
Previously it was showing number of all IfcPresentationStyles
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user