mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Add support for groups in selection queries
This commit is contained in:
@@ -328,6 +328,9 @@ def draw_filter(layout, filter_groups, data, module):
|
||||
elif ifc_filter.type == "location":
|
||||
row = box.row(align=True)
|
||||
row.prop(ifc_filter, "value", text="", icon="PACKAGE")
|
||||
elif ifc_filter.type == "group":
|
||||
row = box.row(align=True)
|
||||
row.prop(ifc_filter, "value", text="", icon="OUTLINER_COLLECTION")
|
||||
elif ifc_filter.type == "query":
|
||||
row = box.row(align=True)
|
||||
row.prop(ifc_filter, "name", text="", icon="POINTCLOUD_DATA")
|
||||
|
||||
@@ -116,8 +116,9 @@ class BIMSearchProperties(PropertyGroup):
|
||||
("classification", "Classification", "", "OUTLINER", 4),
|
||||
("location", "Location", "", "PACKAGE", 5),
|
||||
("type", "Type", "", "FILE_VOLUME", 6),
|
||||
("query", "Query", "", "POINTCLOUD_DATA", 7),
|
||||
("instance", "GlobalId", "", "GRIP", 8),
|
||||
("group", "Group", "", "OUTLINER_COLLECTION", 7),
|
||||
("query", "Query", "", "POINTCLOUD_DATA", 8),
|
||||
("instance", "GlobalId", "", "GRIP", 9),
|
||||
],
|
||||
)
|
||||
saved_searches: EnumProperty(items=get_saved_searches, name="Saved Searches")
|
||||
|
||||
@@ -72,6 +72,9 @@ class Search(blenderbim.core.tool.Search):
|
||||
elif ifc_filter.type == "location":
|
||||
comparison, value = cls.get_comparison_and_value(ifc_filter)
|
||||
filter_group_query.append(f"location{comparison}{value}")
|
||||
elif ifc_filter.type == "group":
|
||||
comparison, value = cls.get_comparison_and_value(ifc_filter)
|
||||
filter_group_query.append(f"group{comparison}{value}")
|
||||
elif ifc_filter.type == "query":
|
||||
keys = cls.wrap_value(ifc_filter, ifc_filter.name)
|
||||
comparison, value = cls.get_comparison_and_value(ifc_filter)
|
||||
@@ -173,6 +176,10 @@ class ImportFilterQueryTransformer(lark.Transformer):
|
||||
comparison, value = args
|
||||
return {"type": "location", "value": f"{comparison}{value}"}
|
||||
|
||||
def group(self, args):
|
||||
comparison, value = args
|
||||
return {"type": "group", "value": f"{comparison}{value}"}
|
||||
|
||||
def query(self, args):
|
||||
keys, comparison, value = args
|
||||
return {"type": "query", "name": keys, "value": f"{comparison}{value}"}
|
||||
|
||||
@@ -33,7 +33,7 @@ filter_elements_grammar = lark.Lark(
|
||||
filter_group: facet_list ("+" facet_list)*
|
||||
facet_list: facet ("," facet)*
|
||||
|
||||
facet: instance | entity | attribute | type | material | query | classification | location | property
|
||||
facet: instance | entity | attribute | type | material | query | classification | location | property | group
|
||||
|
||||
instance: not? globalid
|
||||
globalid: /[0-3][a-zA-Z0-9_$]{21}/
|
||||
@@ -44,6 +44,7 @@ filter_elements_grammar = lark.Lark(
|
||||
property: pset "." prop comparison value
|
||||
classification: "classification" comparison value
|
||||
location: "location" comparison value
|
||||
group: "group" comparison value
|
||||
query: "query:" keys comparison value
|
||||
|
||||
pset: quoted_string | regex_string | unquoted_string
|
||||
@@ -512,6 +513,19 @@ class FacetTransformer(lark.Transformer):
|
||||
|
||||
self.elements = set(filter(filter_function, self.elements))
|
||||
|
||||
def group(self, args):
|
||||
comparison, value = args
|
||||
|
||||
def filter_function(element):
|
||||
result = False
|
||||
for rel in getattr(element, "HasAssignments", []):
|
||||
if rel.is_a("IfcRelAssignsToGroup") and rel.RelatingGroup:
|
||||
if self.compare(rel.RelatingGroup.Name, comparison, value):
|
||||
result = True
|
||||
return result if comparison == "=" else not result
|
||||
|
||||
self.elements = set(filter(filter_function, self.elements))
|
||||
|
||||
def query(self, args):
|
||||
keys, comparison, value = args
|
||||
|
||||
|
||||
Reference in New Issue
Block a user