mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
updated document ui
This commit is contained in:
@@ -55,6 +55,7 @@ def draw_attributes(
|
||||
layout: bpy.types.UILayout,
|
||||
copy_operator: Optional[str] = None,
|
||||
popup_active_attribute: Optional[bonsai.bim.prop.Attribute] = None,
|
||||
filter_attributes: list[str] = None,
|
||||
callback: Optional[Callable[[bonsai.bim.prop.Attribute, bpy.types.UILayout], None]] = None,
|
||||
*,
|
||||
enable_search: Union[bool, EllipsisType] = ...,
|
||||
@@ -75,6 +76,8 @@ def draw_attributes(
|
||||
|
||||
"""
|
||||
for attribute in props:
|
||||
if attribute.name in (filter_attributes or []):
|
||||
continue
|
||||
row = layout.row(align=True)
|
||||
if attribute == popup_active_attribute:
|
||||
row.activate_init = True
|
||||
|
||||
@@ -68,7 +68,10 @@ class BIM_PT_documents(Panel):
|
||||
row.operator("bim.edit_document", text="", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_document", text="", icon="CANCEL")
|
||||
else:
|
||||
row.operator("bim.add_information", text="", icon="ADD")
|
||||
if not self.props.documents or not self.props.active_document_index < len(self.props.documents) or \
|
||||
(self.props.active_document_index < len(self.props.documents) and
|
||||
self.props.documents[self.props.active_document_index].is_information):
|
||||
row.operator("bim.add_information", text="", icon="ADD")
|
||||
|
||||
if self.props.documents and self.props.active_document_index < len(self.props.documents):
|
||||
active_doc = self.props.documents[self.props.active_document_index]
|
||||
@@ -81,10 +84,10 @@ class BIM_PT_documents(Panel):
|
||||
row.operator("bim.select_document_objects", text="", icon="RESTRICT_SELECT_OFF").document = (
|
||||
ifc_definition_id
|
||||
)
|
||||
|
||||
row.operator("bim.assign_document", text="", icon="BRUSH_DATA").document = ifc_definition_id
|
||||
row.operator("bim.enable_editing_document", text="", icon="GREASEPENCIL").document = ifc_definition_id
|
||||
row.operator("bim.remove_document", text="", icon="X").document = ifc_definition_id
|
||||
|
||||
self.layout.template_list("BIM_UL_documents", "", self.props, "documents", self.props, "active_document_index")
|
||||
|
||||
if self.props.is_document_editing:
|
||||
@@ -185,10 +188,12 @@ class BIM_PT_object_documents(Panel):
|
||||
for doc in ObjectDocumentData.data["documents"]:
|
||||
assigned_doc_ids.append(doc["id"])
|
||||
|
||||
if document.ifc_definition_id not in assigned_doc_ids:
|
||||
# Only show assign button if the document is information (not reference) and not already assigned
|
||||
if (document.is_information and
|
||||
document.ifc_definition_id not in assigned_doc_ids):
|
||||
doc_op = row.operator("bim.assign_document", text="", icon="BRUSH_DATA")
|
||||
doc_op.document = document.ifc_definition_id # Pass the current document's ID
|
||||
else:
|
||||
elif document.ifc_definition_id in assigned_doc_ids:
|
||||
row.label(text="", icon="CHECKMARK")
|
||||
|
||||
self.layout.template_list(
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
import bpy
|
||||
import json
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bpy
|
||||
import json
|
||||
import ifcopenshell
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
@@ -69,15 +69,12 @@ class Document(bonsai.core.tool.Document):
|
||||
data[attr_name] = ""
|
||||
return True
|
||||
if attr_name != "Name":
|
||||
return None # Proceed normally
|
||||
return None
|
||||
|
||||
current_value = data[attr_name]
|
||||
# If Name is already filled, display it so user would be able to correct invalid IFC.
|
||||
if current_value is not None:
|
||||
return None
|
||||
|
||||
# Skip import since IFC restricts Name to be filled
|
||||
# for IfcDocumentReference with ReferencedDocument.
|
||||
return False
|
||||
|
||||
import_callback = callback if document.is_a("IfcDocumentReference") else None
|
||||
@@ -199,20 +196,24 @@ class Document(bonsai.core.tool.Document):
|
||||
if has_children and new.is_expanded:
|
||||
children = document_children[doc_id]
|
||||
|
||||
children.sort(
|
||||
info_children = [d for d in children if d.is_a("IfcDocumentInformation")]
|
||||
ref_children = [d for d in children if not d.is_a("IfcDocumentInformation")]
|
||||
|
||||
info_children.sort(
|
||||
key=lambda doc: (
|
||||
doc.is_a("IfcDocumentInformation"),
|
||||
(
|
||||
cls.get_document_information_id(doc)
|
||||
if doc.is_a("IfcDocumentInformation")
|
||||
else cls.get_external_reference_id(doc) or ""
|
||||
).lower(),
|
||||
(doc.Name or "").lower(),
|
||||
),
|
||||
reverse=True,
|
||||
(cls.get_document_information_id(doc) or "").lower(),
|
||||
(doc.Name or "").lower()
|
||||
)
|
||||
)
|
||||
|
||||
for child in children:
|
||||
|
||||
ref_children.sort(
|
||||
key=lambda doc: (
|
||||
(cls.get_external_reference_id(doc) or "").lower(),
|
||||
(doc.Description or doc.Name or "").lower()
|
||||
)
|
||||
)
|
||||
|
||||
for child in info_children + ref_children:
|
||||
cls._process_document(child, props, document_children, expanded_documents, depth + 1)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user