diff --git a/src/blenderbim/blenderbim/bim/module/search/operator.py b/src/blenderbim/blenderbim/bim/module/search/operator.py index 75b5792ba7..cc726844e0 100644 --- a/src/blenderbim/blenderbim/bim/module/search/operator.py +++ b/src/blenderbim/blenderbim/bim/module/search/operator.py @@ -527,7 +527,11 @@ class FilterModelElements(Operator): if f.selector == "IfcPropertySet": selection += f'{f.active_option.split(": ")[1]}.{f.active_sub_option.split(": ")[1]} {"!" if f.negation else ""}{comparison_operator} "{f.value}"' elif f.selector == "Attribute": - selection += f'{f.attribute} {"!" if f.negation else ""}{comparison_operator} "{f.value}"' + # we're using the prop_search functionality in blender which returns the index of the option. Sometimes the user can override this and enter a value that doesn't exist in the list. In this case there is no index and we need to handle it. @vulevukusej + pattern = re.compile(r'^[0-9]+:') + match = pattern.search(f.active_option) + + selection += f'{f.active_option.split(": ")[1] if match else f.active_option} {"!" if f.negation else ""}{comparison_operator} "{f.value}"' selection += "]" return selection diff --git a/src/blenderbim/blenderbim/bim/module/search/prop.py b/src/blenderbim/blenderbim/bim/module/search/prop.py index c1c7826ffe..8fd8cc8bb7 100644 --- a/src/blenderbim/blenderbim/bim/module/search/prop.py +++ b/src/blenderbim/blenderbim/bim/module/search/prop.py @@ -130,6 +130,10 @@ def load_selection_options(self, context): elif self.selector == "IfcPropertySet": psets = Selector.parse(ifc, ".IfcPropertySet") options = set([o.Name for o in psets]) + elif self.selector == "Attribute": + attributes = ["GlobalId", "Name", "Description", "ObjectType", "Tag", "PredefinedType"] + for a in attributes: + options.append((a, a, "")) elif load_option == "sub_options": if self.selector in ["IfcSpatialElement", "IfcElementType"]: @@ -208,11 +212,6 @@ class SearchQueryFilter(PropertyGroup, IfcSelector): update=load_selection_options, default="-", ) - attribute: EnumProperty( - items=[(i, i, i) for i in ["GlobalId", "Name", "Description", "ObjectType", "Tag", "PredefinedType"]], - name="Filter selection by", - update=load_selection_options, - ) class SearchQuery(PropertyGroup, IfcSelector): diff --git a/src/blenderbim/blenderbim/bim/module/search/ui.py b/src/blenderbim/blenderbim/bim/module/search/ui.py index fcec6ec14d..bcd9ac3077 100644 --- a/src/blenderbim/blenderbim/bim/module/search/ui.py +++ b/src/blenderbim/blenderbim/bim/module/search/ui.py @@ -224,7 +224,7 @@ class IfcSelectorUI: row.prop(f, "selector", text="") if f.selector == "Attribute": - row.prop(f, "attribute", text="") + row.prop_search(f, "active_option", f, "options", text="", results_are_suggestions=True) row.prop( f, "negation",