mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:23:41 +00:00
selector now correctly applies comparison operator. #2643
This commit is contained in:
@@ -480,7 +480,7 @@ class FilterModelElements(Operator):
|
|||||||
self.update_model_view(context, selection)
|
self.update_model_view(context, selection)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def add_groups(self, selector):
|
def add_groups(self, selector:str) -> str:
|
||||||
selection = ""
|
selection = ""
|
||||||
for group_index, group in enumerate(selector.groups):
|
for group_index, group in enumerate(selector.groups):
|
||||||
if group_index != 0:
|
if group_index != 0:
|
||||||
@@ -491,7 +491,7 @@ class FilterModelElements(Operator):
|
|||||||
selection += ")" if len(selector.groups) > 1 else ""
|
selection += ")" if len(selector.groups) > 1 else ""
|
||||||
return selection
|
return selection
|
||||||
|
|
||||||
def add_queries(self, selection, group):
|
def add_queries(self, selection: str, group: str) -> str:
|
||||||
for query_index, query in enumerate(group.queries):
|
for query_index, query in enumerate(group.queries):
|
||||||
if query_index != 0:
|
if query_index != 0:
|
||||||
selection += " & " if query.and_or == "and" else " | "
|
selection += " & " if query.and_or == "and" else " | "
|
||||||
@@ -513,9 +513,11 @@ class FilterModelElements(Operator):
|
|||||||
selection += f"@ #{query.sub_options[index].global_id}"
|
selection += f"@ #{query.sub_options[index].global_id}"
|
||||||
return selection
|
return selection
|
||||||
|
|
||||||
def add_filters(self, selection, query):
|
def add_filters(self, selection: str, query: str) -> str:
|
||||||
for f_index, f in enumerate(query.filters):
|
for f_index, f in enumerate(query.filters):
|
||||||
|
|
||||||
|
comparison_operator = f.comparison
|
||||||
|
|
||||||
if f_index != 0:
|
if f_index != 0:
|
||||||
selection += " & " if f.and_or == "and" else " | "
|
selection += " & " if f.and_or == "and" else " | "
|
||||||
selection += f".{query.active_option}"
|
selection += f".{query.active_option}"
|
||||||
@@ -523,19 +525,19 @@ class FilterModelElements(Operator):
|
|||||||
selection += "["
|
selection += "["
|
||||||
|
|
||||||
if f.selector == "IfcPropertySet":
|
if f.selector == "IfcPropertySet":
|
||||||
selection += f'{f.active_option.split(": ")[1]}.{f.active_sub_option.split(": ")[1]} {"!" if f.negation else ""}="{f.value}"'
|
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":
|
elif f.selector == "Attribute":
|
||||||
selection += f'{f.attribute} {"!" if f.negation else ""}= "{f.value}"'
|
selection += f'{f.attribute} {"!" if f.negation else ""}{comparison_operator} "{f.value}"'
|
||||||
|
|
||||||
selection += "]"
|
selection += "]"
|
||||||
return selection
|
return selection
|
||||||
|
|
||||||
def update_model_view(self, context, selection):
|
def update_model_view(self, context, selection: str) -> None:
|
||||||
query = Selector.parse(IfcStore.file, selection)
|
query = Selector.parse(IfcStore.file, selection)
|
||||||
sel_element_ids = [e.id() for e in query]
|
sel_element_ids = [e.id() for e in query]
|
||||||
bpy.ops.object.select_all(action="DESELECT")
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
|
|
||||||
for obj in context.visible_objects:
|
for obj in bpy.data.scenes["Scene"].objects:
|
||||||
obj.hide_set(False) # reset 3d view
|
obj.hide_set(False) # reset 3d view
|
||||||
|
|
||||||
if self.option == "select":
|
if self.option == "select":
|
||||||
|
|||||||
Reference in New Issue
Block a user