mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Project Library UI - allow expanding libraries hierarchy even if there are no assets yet
This commit is contained in:
@@ -237,7 +237,7 @@ class RefreshLibrary(bpy.types.Operator):
|
||||
elements.update(library_file.by_type(importable_type))
|
||||
rels = tool.Project.get_project_library_rels(library_file)
|
||||
elements = {e for e in elements if not tool.Project.is_element_assigned_to_project_library(e, rels)}
|
||||
self.props.add_library_project_library("Unassigned", len(elements), 0)
|
||||
self.props.add_library_project_library("Unassigned", len(elements), 0, False)
|
||||
|
||||
ifc_project = library_file.by_type("IfcProject")[0]
|
||||
hierarchy = tool.Project.get_project_hierarchy(library_file)
|
||||
|
||||
@@ -180,6 +180,8 @@ class LibraryElement(PropertyGroup):
|
||||
element_type: EnumProperty(items=[(i, i, "") for i in get_args(LibraryElementType)], name="Element Type")
|
||||
# Asset group.
|
||||
asset_count: IntProperty(name="Asset Count")
|
||||
# Asset library.
|
||||
has_sublibraries: BoolProperty(name="Has Sublibraries", default=False)
|
||||
# Asset.
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
is_declared: BoolProperty(name="Is Declared", default=False)
|
||||
@@ -194,6 +196,7 @@ class LibraryElement(PropertyGroup):
|
||||
name: str
|
||||
element_type: LibraryElementType
|
||||
asset_count: int
|
||||
has_sublibraries: bool
|
||||
ifc_definition_id: int
|
||||
is_declared: bool
|
||||
is_appended: bool
|
||||
@@ -402,12 +405,15 @@ class BIMProjectProperties(PropertyGroup):
|
||||
def clipping_planes_objs(self) -> list[bpy.types.Object]:
|
||||
return list({cp.obj for cp in self.clipping_planes if cp.obj})
|
||||
|
||||
def add_library_project_library(self, name: str, asset_count: int, ifc_definition_id: int) -> LibraryElement:
|
||||
def add_library_project_library(
|
||||
self, name: str, asset_count: int, ifc_definition_id: int, has_sublibraries: bool
|
||||
) -> LibraryElement:
|
||||
new = self.library_elements.add()
|
||||
new["name"] = name
|
||||
new.asset_count = asset_count
|
||||
new.element_type = "LIBRARY"
|
||||
new.ifc_definition_id = ifc_definition_id
|
||||
new.has_sublibraries = has_sublibraries
|
||||
return new
|
||||
|
||||
def add_library_asset_class(self, name: str, asset_count: int) -> LibraryElement:
|
||||
|
||||
@@ -512,7 +512,7 @@ class BIM_UL_library(UIList):
|
||||
):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
if item.element_type != "ASSET" and item.asset_count > 0:
|
||||
if item.element_type != "ASSET" and (item.asset_count > 0 or item.has_sublibraries):
|
||||
op = row.operator("bim.change_library_element", text="", icon="DISCLOSURE_TRI_RIGHT", emboss=False)
|
||||
op.element_name = item.name
|
||||
op.breadcrumb_type = item.element_type
|
||||
|
||||
@@ -377,7 +377,7 @@ class Project(bonsai.core.tool.Project):
|
||||
sublibrary_elements = tool.Project.get_project_library_elements(sublibrary)
|
||||
library_elements.update(sublibrary_elements)
|
||||
props.add_library_project_library(
|
||||
project_library.Name or "Unnamed", len(library_elements), project_library.id()
|
||||
project_library.Name or "Unnamed", len(library_elements), project_library.id(), bool(subhierarchy)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user