mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Zones UI - add buttons for unassigning zone from the active objects
This commit is contained in:
@@ -23,6 +23,7 @@ import ifcopenshell.util.system
|
|||||||
import ifcopenshell.util.unit
|
import ifcopenshell.util.unit
|
||||||
from ifcopenshell.util.doc import get_entity_doc
|
from ifcopenshell.util.doc import get_entity_doc
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def refresh():
|
def refresh():
|
||||||
@@ -266,9 +267,15 @@ class ActiveObjectZonesData:
|
|||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def zones(cls):
|
def zones(cls) -> list[dict[str, Any]]:
|
||||||
obj = bpy.context.active_object
|
obj = bpy.context.active_object
|
||||||
assert obj
|
assert obj
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
assert element
|
assert element
|
||||||
return [z.Name or "Unnamed" for z in ifcopenshell.util.system.get_element_zones(element)]
|
return [
|
||||||
|
{
|
||||||
|
"id": z.id(),
|
||||||
|
"Name": (z.Name or "Unnamed"),
|
||||||
|
}
|
||||||
|
for z in ifcopenshell.util.system.get_element_zones(element)
|
||||||
|
]
|
||||||
|
|||||||
@@ -66,14 +66,6 @@ class BIM_PT_systems(Panel):
|
|||||||
if not ObjectSystemData.is_loaded:
|
if not ObjectSystemData.is_loaded:
|
||||||
ObjectSystemData.load()
|
ObjectSystemData.load()
|
||||||
|
|
||||||
def draw_system_ui(row, system_id, system_name, system_class):
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text=system_name, icon=SYSTEM_ICONS[system_class])
|
|
||||||
op = row.operator("bim.select_system_products", text="", icon="RESTRICT_SELECT_OFF")
|
|
||||||
op.system = system_id
|
|
||||||
op = row.operator("bim.unassign_system", text="", icon="X")
|
|
||||||
op.system = system_id
|
|
||||||
|
|
||||||
self.props = tool.System.get_system_props()
|
self.props = tool.System.get_system_props()
|
||||||
active_system_item = self.props.active_system_ui_item
|
active_system_item = self.props.active_system_ui_item
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
@@ -82,8 +74,7 @@ class BIM_PT_systems(Panel):
|
|||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
if active_system := tool.System.get_active_system():
|
if active_system := tool.System.get_active_system():
|
||||||
row.label(text=f"Active system:")
|
row.label(text=f"Active system:")
|
||||||
row = self.layout.row(align=True)
|
tool.System.draw_system_ui(self.layout, active_system.id(), active_system.Name, active_system.is_a())
|
||||||
draw_system_ui(row, active_system.id(), active_system.Name, active_system.is_a())
|
|
||||||
else:
|
else:
|
||||||
row.label(text="No active system is selected")
|
row.label(text="No active system is selected")
|
||||||
|
|
||||||
@@ -91,8 +82,7 @@ class BIM_PT_systems(Panel):
|
|||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.label(text="Active object systems:")
|
row.label(text="Active object systems:")
|
||||||
for system in ObjectSystemData.data["systems"]:
|
for system in ObjectSystemData.data["systems"]:
|
||||||
row = self.layout.row(align=True)
|
tool.System.draw_system_ui(self.layout, system["id"], system["name"], system["ifc_class"])
|
||||||
draw_system_ui(row, system["id"], system["name"], system["ifc_class"])
|
|
||||||
else:
|
else:
|
||||||
self.layout.label(text="No System associated with active object")
|
self.layout.label(text="No System associated with active object")
|
||||||
|
|
||||||
@@ -416,8 +406,7 @@ class BIM_PT_active_object_zones(Panel):
|
|||||||
self.props = tool.System.get_zone_props()
|
self.props = tool.System.get_zone_props()
|
||||||
|
|
||||||
for zone in ActiveObjectZonesData.data["zones"]:
|
for zone in ActiveObjectZonesData.data["zones"]:
|
||||||
row = self.layout.row()
|
tool.System.draw_system_ui(self.layout, zone["id"], zone["Name"], "IfcZone")
|
||||||
row.label(text=zone, icon="SEQ_STRIP_META")
|
|
||||||
|
|
||||||
if not ActiveObjectZonesData.data["zones"]:
|
if not ActiveObjectZonesData.data["zones"]:
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
|
|||||||
@@ -426,3 +426,14 @@ class System(bonsai.core.tool.System):
|
|||||||
if not element.AssignedToFlowElement:
|
if not element.AssignedToFlowElement:
|
||||||
return
|
return
|
||||||
return element.AssignedToFlowElement[0].RelatingFlowElement
|
return element.AssignedToFlowElement[0].RelatingFlowElement
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def draw_system_ui(cls, layout: bpy.types.UILayout, system_id: int, system_name: str, system_class: str) -> None:
|
||||||
|
from bonsai.bim.module.system.ui import SYSTEM_ICONS
|
||||||
|
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.label(text=system_name, icon=SYSTEM_ICONS[system_class])
|
||||||
|
op = row.operator("bim.select_system_products", text="", icon="RESTRICT_SELECT_OFF")
|
||||||
|
op.system = system_id
|
||||||
|
op = row.operator("bim.unassign_system", text="", icon="X")
|
||||||
|
op.system = system_id
|
||||||
|
|||||||
Reference in New Issue
Block a user