From 819db11db4c2e7bbfeb2284c77208c301c62b473 Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Fri, 28 Oct 2022 15:44:31 +0200 Subject: [PATCH] Simplify attribute description --- src/blenderbim/blenderbim/bim/helper.py | 20 +++++++++---------- .../bim/module/material/operator.py | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/helper.py b/src/blenderbim/blenderbim/bim/helper.py index 3bddd84159..28ee216a26 100644 --- a/src/blenderbim/blenderbim/bim/helper.py +++ b/src/blenderbim/blenderbim/bim/helper.py @@ -84,6 +84,7 @@ def import_attribute(attribute, props, data, callback=None): new.is_null = data[attribute.name()] is None new.is_optional = attribute.optional() new.data_type = data_type if isinstance(data_type, str) else "" + new.ifc_class = data["type"] is_handled_by_callback = callback(attribute.name(), new, data) if callback else None if is_handled_by_callback: @@ -103,27 +104,26 @@ def import_attribute(attribute, props, data, callback=None): elif data_type == "enum": enum_items = ifcopenshell.util.attribute.get_enum_items(attribute) new.enum_items = json.dumps(enum_items) - add_attribute_enum_items_descriptions(data["type"], new, enum_items) + add_attribute_enum_items_descriptions(new, enum_items) if data[new.name]: new.enum_value = data[new.name] - add_attribute_description(data["type"], new) - new.ifc_class = data["type"] + add_attribute_description(new) -def add_attribute_enum_items_descriptions(ifc_class, new_attribute, enum_items): - new_attribute.enum_descriptions.clear() +def add_attribute_enum_items_descriptions(attribute_blender, enum_items): + attribute_blender.enum_descriptions.clear() if isinstance(enum_items, dict): enum_items = enum_items.keys() for enum_item in enum_items: - new_enum_description = new_attribute.enum_descriptions.add() + new_enum_description = attribute_blender.enum_descriptions.add() # TODO this only supports predefined type enums. Add support for other types of enums ? - new_enum_description.name = get_predefined_type_description(ifc_class, enum_item) or "" + new_enum_description.name = get_predefined_type_description(attribute_blender.ifc_class, enum_item) or "" -def add_attribute_description(ifc_class, new_attribute): - description = get_attribute_description(ifc_class, new_attribute.name) +def add_attribute_description(attribute_blender): + description = get_attribute_description(attribute_blender.ifc_class, attribute_blender.name) if description: - new_attribute.description = description + attribute_blender.description = description def export_attributes(props, callback=None): diff --git a/src/blenderbim/blenderbim/bim/module/material/operator.py b/src/blenderbim/blenderbim/bim/module/material/operator.py index 0fb38a79b0..49873808af 100644 --- a/src/blenderbim/blenderbim/bim/module/material/operator.py +++ b/src/blenderbim/blenderbim/bim/module/material/operator.py @@ -613,6 +613,7 @@ class EnableEditingMaterialSetItem(bpy.types.Operator): continue if attribute.name() in material_set_item_data: new = self.props.material_set_item_attributes.add() + new.ifc_class = material_set_item.is_a() new.name = attribute.name() new.is_null = material_set_item_data[attribute.name()] is None new.data_type = data_type @@ -624,9 +625,8 @@ class EnableEditingMaterialSetItem(bpy.types.Operator): new.int_value = 0 if new.is_null else material_set_item_data[attribute.name()] elif data_type == "boolean": new.bool_value = False if new.is_null else material_set_item_data[attribute.name()] - blenderbim.bim.helper.add_attribute_description(material_set_item.is_a(), new) - new.ifc_class = material_set_item.is_a() - + blenderbim.bim.helper.add_attribute_description(new) + def load_profile_attributes(self, material_set_item, material_set_item_data): self.props.material_set_item_profile_attributes.clear() @@ -643,6 +643,7 @@ class EnableEditingMaterialSetItem(bpy.types.Operator): if attribute.name() in profile_data: new = self.props.material_set_item_profile_attributes.add() new.name = attribute.name() + new.ifc_class = profile.is_a() new.is_null = profile_data[attribute.name()] is None new.is_optional = attribute.optional() new.data_type = data_type @@ -659,8 +660,7 @@ class EnableEditingMaterialSetItem(bpy.types.Operator): if profile_data[attribute.name()]: new.enum_value = profile_data[attribute.name()] - blenderbim.bim.helper.add_attribute_description(profile.is_a(), new) - new.ifc_class = profile.is_a() + blenderbim.bim.helper.add_attribute_description(new) # Force null to be false if the attribute is mandatory because when we first assign a profile, all of # its fields are null (which is illegal).