diff --git a/src/blenderbim/blenderbim/bim/module/root/prop.py b/src/blenderbim/blenderbim/bim/module/root/prop.py index 3a003d368e..6a28a40b51 100644 --- a/src/blenderbim/blenderbim/bim/module/root/prop.py +++ b/src/blenderbim/blenderbim/bim/module/root/prop.py @@ -72,7 +72,8 @@ def refreshPredefinedTypes(self, context): global types_enum types_enum.clear() enum = getIfcPredefinedTypes(self, context) - context.scene.BIMRootProperties.ifc_predefined_type = enum[0][0] + if enum: + context.scene.BIMRootProperties.ifc_predefined_type = enum[0][0] def getIfcProducts(self, context): diff --git a/src/blenderbim/blenderbim/bim/module/root/ui.py b/src/blenderbim/blenderbim/bim/module/root/ui.py index 60e816f496..aa2ea98ec2 100644 --- a/src/blenderbim/blenderbim/bim/module/root/ui.py +++ b/src/blenderbim/blenderbim/bim/module/root/ui.py @@ -18,6 +18,7 @@ # along with BlenderBIM Add-on. If not, see . import bpy +import blenderbim.bim.module.root.prop as root_prop from bpy.types import Panel from ifcopenshell.api.root.data import Data from blenderbim.bim.ifc import IfcStore @@ -49,7 +50,9 @@ class BIM_PT_class(Panel): row = self.layout.row(align=True) row.operator("bim.reassign_class", icon="CHECKMARK") row.operator("bim.disable_reassign_class", icon="CANCEL", text="") - self.draw_class_dropdowns(context) + self.draw_class_dropdowns( + context, + root_prop.getIfcPredefinedTypes(context.scene.BIMRootProperties, context)) else: data = Data.products[props.ifc_definition_id] name = data["type"] @@ -72,23 +75,24 @@ class BIM_PT_class(Panel): else: row.operator("bim.unassign_class", icon="X", text="").obj = context.active_object.name else: - self.draw_class_dropdowns(context) + ifc_predefined_types = root_prop.getIfcPredefinedTypes(context.scene.BIMRootProperties, context) + self.draw_class_dropdowns(context, ifc_predefined_types) row = self.layout.row(align=True) op = row.operator("bim.assign_class") op.ifc_class = context.scene.BIMRootProperties.ifc_class - op.predefined_type = context.scene.BIMRootProperties.ifc_predefined_type + op.predefined_type = context.scene.BIMRootProperties.ifc_predefined_type if ifc_predefined_types else "" op.userdefined_type = context.scene.BIMRootProperties.ifc_userdefined_type - def draw_class_dropdowns(self, context): + def draw_class_dropdowns(self, context, ifc_predefined_types): props = context.scene.BIMRootProperties row = self.layout.row() row.prop(props, "ifc_product") row = self.layout.row() row.prop(props, "ifc_class") - if props.ifc_predefined_type: + if ifc_predefined_types: row = self.layout.row() row.prop(props, "ifc_predefined_type") - if props.ifc_predefined_type == "USERDEFINED": + if ifc_predefined_types == "USERDEFINED": row = self.layout.row() row.prop(props, "ifc_userdefined_type") row = self.layout.row()