Poll check for show/hide ports

https://i.imgur.com/NFAM1UC.png
This commit is contained in:
Andrej730
2023-08-01 15:53:28 +05:00
parent 8c21c74ff5
commit 72c2ef1dd1
@@ -22,6 +22,7 @@ import blenderbim.tool as tool
import blenderbim.core.system as core
import blenderbim.bim.handler
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.system.data import PortData
class Operator:
@@ -139,6 +140,15 @@ class ShowPorts(bpy.types.Operator, Operator):
bl_label = "Show Ports"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
if not PortData.is_loaded:
PortData.load()
if PortData.data["total_ports"] == 0:
cls.poll_message_set("No ports found")
return False
return True
def _execute(self, context):
core.show_ports(tool.Ifc, tool.System, tool.Spatial, element=tool.Ifc.get_entity(context.active_object))
@@ -148,6 +158,10 @@ class HidePorts(bpy.types.Operator, Operator):
bl_label = "Hide Ports"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return ShowPorts.poll(context)
def _execute(self, context):
core.hide_ports(tool.Ifc, tool.System, element=tool.Ifc.get_entity(context.active_object))