diff --git a/src/blenderbim/blenderbim/bim/module/classification/data.py b/src/blenderbim/blenderbim/bim/module/classification/data.py index 369b087b13..46c5c3c591 100644 --- a/src/blenderbim/blenderbim/bim/module/classification/data.py +++ b/src/blenderbim/blenderbim/bim/module/classification/data.py @@ -117,12 +117,16 @@ class MaterialClassificationsData(ReferencesData): @classmethod def references(cls): results = [] - element = tool.Ifc.get_entity(bpy.context.active_object.active_material) - if element: - for reference in ifcopenshell.util.classification.get_references(element): - data = reference.get_info() - del data["ReferencedSource"] - results.append(data) + + props = bpy.context.scene.BIMMaterialProperties + if props.materials and props.active_material_index < len(props.materials): + material = props.materials[props.active_material_index] + if material.ifc_definition_id: + element = tool.Ifc.get().by_id(material.ifc_definition_id) + for reference in ifcopenshell.util.classification.get_references(element): + data = reference.get_info() + del data["ReferencedSource"] + results.append(data) return results diff --git a/src/blenderbim/blenderbim/bim/module/classification/ui.py b/src/blenderbim/blenderbim/bim/module/classification/ui.py index 3423545462..2e165c76c1 100644 --- a/src/blenderbim/blenderbim/bim/module/classification/ui.py +++ b/src/blenderbim/blenderbim/bim/module/classification/ui.py @@ -118,7 +118,6 @@ class BIM_PT_classifications(Panel): class ReferenceUI: def draw_ui(self, context): obj = context.active_object - self.oprops = obj.BIMObjectProperties self.sprops = context.scene.BIMClassificationProperties self.bprops = context.scene.BIMBSDDProperties self.props = obj.BIMClassificationReferenceProperties @@ -295,22 +294,25 @@ class BIM_PT_material_classifications(Panel, ReferenceUI): bl_options = {"DEFAULT_CLOSED"} bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" - bl_context = "material" + bl_context = "scene" + bl_parent_id = "BIM_PT_materials" @classmethod def poll(cls, context): if not tool.Ifc.get(): return False - try: - return bool(context.active_object.active_material.BIMObjectProperties.ifc_definition_id) - except: - return False + props = context.scene.BIMMaterialProperties + if props.materials and props.active_material_index < len(props.materials): + material = props.materials[props.active_material_index] + if material.ifc_definition_id: + return True + return False def draw(self, context): if not MaterialClassificationsData.is_loaded: MaterialClassificationsData.load() self.data = MaterialClassificationsData - self.obj = context.active_object.active_material.name + self.obj = "" self.obj_type = "Material" self.draw_ui(context) diff --git a/src/blenderbim/blenderbim/bim/module/pset/ui.py b/src/blenderbim/blenderbim/bim/module/pset/ui.py index ea5f881f17..4f63ec8063 100644 --- a/src/blenderbim/blenderbim/bim/module/pset/ui.py +++ b/src/blenderbim/blenderbim/bim/module/pset/ui.py @@ -309,7 +309,7 @@ class BIM_PT_material_psets(Panel): row = self.layout.row(align=True) prop_with_search(row, props, "pset_name", text="") op = row.operator("bim.add_pset", icon="ADD", text="") - op.obj = context.active_object.name + op.obj = "" op.obj_type = "Material" if not props.active_pset_id and props.active_pset_name and props.active_pset_type == "PSET":