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