Status UI - display active object status using icons

Example - https://files.catbox.moe/ucrtfg.mp4
This commit is contained in:
Andrej730
2025-09-10 14:03:55 +05:00
parent 12bcf1d2c7
commit f4be8812e2
5 changed files with 71 additions and 1 deletions
@@ -433,6 +433,7 @@ class StatusData:
cls.is_loaded = True
cls.data = {
"statuses_with_elements": cls.statuses_with_elements(),
"active_element_status": cls.active_element_status(),
}
@classmethod
@@ -444,3 +445,9 @@ class StatusData:
if tool.Sequence.get_elements_by_status(status):
statuses_used.add(status)
return statuses_used
@classmethod
def active_element_status(cls) -> set[str]:
if not (obj := bpy.context.active_object) or not (element := tool.Ifc.get_entity(obj)):
return set()
return tool.Sequence.get_element_status(element)
@@ -72,6 +72,8 @@ class BIM_PT_status(Panel):
for status in self.props.statuses:
row = box.row(align=True)
row.label(text=status.name)
if status.name in StatusData.data["active_element_status"]:
row.label(text="", icon="OBJECT_DATA")
if status.name in StatusData.data["statuses_with_elements"]:
row.label(text="", icon="ASSET_MANAGER")
row.prop(status, "is_visible", text="", emboss=False, icon="HIDE_OFF" if status.is_visible else "HIDE_ON")
-1
View File
@@ -888,7 +888,6 @@ class Sequence:
def load_lag_time_attributes(cls, lag_time): pass
def load_product_related_tasks(cls, product): pass
def load_rel_sequence_attributes(cls, rel_sequence): pass
def load_resources(cls): pass
def load_task_attributes(cls, task): pass
def load_task_inputs(cls, inputs): pass
def load_task_outputs(cls, outputs): pass
+12
View File
@@ -23,6 +23,7 @@ import bpy
import json
import base64
import ifcopenshell.api.sequence
import ifcopenshell.util.element
import pystache
import mathutils
import webbrowser
@@ -1879,3 +1880,14 @@ class Sequence(bonsai.core.tool.Sequence):
ifc_file = tool.Ifc.get()
new_schedule = ifcopenshell.api.sequence.copy_work_schedule(ifc_file, work_schedule)
new_schedule.Name = (new_schedule.Name or "Unnamed") + " Copy"
@classmethod
def get_element_status(cls, element: ifcopenshell.entity_instance) -> set[str]:
psets = ifcopenshell.util.element.get_psets(element)
statuses: set[str] = set()
for pset_name, pset_data in psets.items():
if pset_name == "EPset_Status" or (pset_name.startswith("Pset_") and pset_name.endswith("Common")):
if pset_statuses := pset_data.get("Status", None):
assert isinstance(pset_statuses, list)
statuses.update(pset_statuses)
return statuses
+50
View File
@@ -0,0 +1,50 @@
# Bonsai - OpenBIM Blender Add-on
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
#
# This file is part of Bonsai.
#
# Bonsai is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Bonsai is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
import os
import bpy
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.pset
import ifcopenshell.api.root
import bonsai.core.tool
import bonsai.tool as tool
from test.bim.bootstrap import NewFile
from bonsai.tool.sequence import Sequence as subject
class TestImplementsTool(NewFile):
def test_run(self):
assert isinstance(subject(), bonsai.core.tool.Sequence)
class TestGetElementStatus(NewFile):
def test_common_pset(self):
ifc = ifcopenshell.file()
element = ifcopenshell.api.root.create_entity(ifc, "IfcWall")
pset = ifcopenshell.api.pset.add_pset(ifc, element, "Pset_WallCommon")
ifcopenshell.api.pset.edit_pset(ifc, pset, properties={"Status": ["EXISTING", "TEMPORARY"]})
assert subject.get_element_status(element) == {"EXISTING", "TEMPORARY"}
def test_epset(self):
bpy.ops.bim.create_project()
ifc = tool.Ifc.get()
element = ifcopenshell.api.root.create_entity(ifc, "IfcWall")
pset = ifcopenshell.api.pset.add_pset(ifc, element, "EPset_Status")
ifcopenshell.api.pset.edit_pset(ifc, pset, properties={"Status": ["EXISTING", "TEMPORARY"]})
assert subject.get_element_status(element) == {"EXISTING", "TEMPORARY"}