mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 10:06:47 +00:00
context.data - skip passing unnecessary attributes
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
import ifcopenshell
|
||||
from typing import Any
|
||||
|
||||
|
||||
def refresh():
|
||||
@@ -34,7 +36,7 @@ class ContextData:
|
||||
cls.is_loaded = True
|
||||
|
||||
@classmethod
|
||||
def get_contexts(cls):
|
||||
def get_contexts(cls) -> list[dict[str, Any]]:
|
||||
results = []
|
||||
for context in tool.Ifc.get().by_type("IfcGeometricRepresentationContext", include_subtypes=False):
|
||||
results.append(
|
||||
@@ -42,14 +44,12 @@ class ContextData:
|
||||
"id": context.id(),
|
||||
"context_type": context.ContextType,
|
||||
"subcontexts": cls.get_subcontexts(context),
|
||||
"is_editing": bpy.context.scene.BIMContextProperties.active_context_id == context.id(),
|
||||
"props": bpy.context.scene.BIMContextProperties.context_attributes,
|
||||
}
|
||||
)
|
||||
return results
|
||||
|
||||
@classmethod
|
||||
def get_subcontexts(cls, context):
|
||||
def get_subcontexts(cls, context: ifcopenshell.entity_instance) -> list[dict[str, Any]]:
|
||||
results = []
|
||||
for subcontext in context.HasSubContexts:
|
||||
results.append(
|
||||
@@ -58,8 +58,6 @@ class ContextData:
|
||||
"context_type": subcontext.ContextType,
|
||||
"context_identifier": subcontext.ContextIdentifier,
|
||||
"target_view": subcontext.TargetView,
|
||||
"is_editing": bpy.context.scene.BIMContextProperties.active_context_id == subcontext.id(),
|
||||
"props": bpy.context.scene.BIMContextProperties.context_attributes,
|
||||
}
|
||||
)
|
||||
return results
|
||||
|
||||
@@ -52,11 +52,11 @@ class BIM_PT_context(bpy.types.Panel):
|
||||
for ifc_context in ContextData.data["contexts"]:
|
||||
box = self.layout.box()
|
||||
|
||||
if ifc_context["is_editing"]:
|
||||
if props.active_context_id == ifc_context["id"]:
|
||||
row = box.row(align=True)
|
||||
row.operator("bim.edit_context", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_context", icon="CANCEL", text="")
|
||||
bonsai.bim.helper.draw_attributes(ifc_context["props"], box)
|
||||
bonsai.bim.helper.draw_attributes(props.context_attributes, box)
|
||||
else:
|
||||
row = box.row(align=True)
|
||||
row.label(text=ifc_context["context_type"])
|
||||
@@ -73,11 +73,11 @@ class BIM_PT_context(bpy.types.Panel):
|
||||
op.parent = ifc_context["id"]
|
||||
|
||||
for subcontext in ifc_context["subcontexts"]:
|
||||
if subcontext["is_editing"]:
|
||||
if props.active_context_id == subcontext["id"]:
|
||||
row = box.row(align=True)
|
||||
row.operator("bim.edit_context", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_context", icon="CANCEL", text="")
|
||||
bonsai.bim.helper.draw_attributes(subcontext["props"], box)
|
||||
bonsai.bim.helper.draw_attributes(props.context_attributes, box)
|
||||
else:
|
||||
row = box.row(align=True)
|
||||
row.label(text=subcontext["context_type"])
|
||||
|
||||
Reference in New Issue
Block a user