diff --git a/src/blenderbim/blenderbim/bim/module/pset_template/operator.py b/src/blenderbim/blenderbim/bim/module/pset_template/operator.py index b9e86ba16a..1628522e02 100644 --- a/src/blenderbim/blenderbim/bim/module/pset_template/operator.py +++ b/src/blenderbim/blenderbim/bim/module/pset_template/operator.py @@ -21,7 +21,11 @@ import ifcopenshell import ifcopenshell.api import blenderbim.bim.schema import blenderbim.bim.handler -from blenderbim.bim.module.pset_template.prop import updatePsetTemplateFiles, updatePsetTemplates +from blenderbim.bim.module.pset_template.prop import ( + updatePsetTemplateFiles, + updatePsetTemplates, + getPsetTemplates +) from ifcopenshell.api.pset_template.data import Data from blenderbim.bim.ifc import IfcStore @@ -59,6 +63,11 @@ class RemovePsetTemplate(bpy.types.Operator): bl_label = "Remove Pset Template" bl_options = {"REGISTER", "UNDO"} + @classmethod + def poll(cls, context): + props = context.scene.BIMPsetTemplateProperties + return bool(getPsetTemplates(props, context)) + def execute(self, context): IfcStore.begin_transaction(self) IfcStore.pset_template_file.begin_transaction() @@ -93,6 +102,11 @@ class EnableEditingPsetTemplate(bpy.types.Operator): bl_label = "Enable Editing Pset Template" bl_options = {"REGISTER", "UNDO"} + @classmethod + def poll(cls, context): + props = context.scene.BIMPsetTemplateProperties + return bool(getPsetTemplates(props, context)) + def execute(self, context): props = context.scene.BIMPsetTemplateProperties props.active_pset_template_id = int(props.pset_templates) diff --git a/src/blenderbim/blenderbim/bim/module/pset_template/ui.py b/src/blenderbim/blenderbim/bim/module/pset_template/ui.py index 0049612fd5..b0068f365c 100644 --- a/src/blenderbim/blenderbim/bim/module/pset_template/ui.py +++ b/src/blenderbim/blenderbim/bim/module/pset_template/ui.py @@ -19,6 +19,9 @@ import bpy from bpy.types import Panel from blenderbim.bim.ifc import IfcStore +from blenderbim.bim.module.pset_template.prop import ( + getPsetTemplates, +) from ifcopenshell.api.pset_template.data import Data @@ -40,7 +43,7 @@ class BIM_PT_pset_template(Panel): row = layout.row(align=True) - if props.pset_templates: + if bool(getPsetTemplates(props, context)): row.prop(props, "pset_templates", text="", icon="COPY_ID") else: row.label(text="No Pset Templates", icon="COPY_ID")