Fix #4815. Purge deprecated old selector syntax.

This commit is contained in:
Dion Moult
2024-06-07 20:08:11 +10:00
parent f565b4e8f0
commit f0a19cb054
11 changed files with 128 additions and 665 deletions
@@ -31,7 +31,6 @@ classes = (
operator.SelectGroupProducts,
operator.ToggleGroup,
operator.UnassignGroup,
operator.UpdateGroup,
operator.SelectGroupElements,
prop.ExpandedGroups,
prop.Group,
@@ -22,7 +22,6 @@ import ifcopenshell.api
import blenderbim.bim.helper
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
from ifcopenshell.util.selector import Selector
import json
@@ -48,7 +47,6 @@ class LoadGroups(bpy.types.Operator, tool.Ifc.Operator):
new = self.props.groups.add()
new.ifc_definition_id = group.id()
new.name = group.Name or "Unnamed"
new.selection_query = ""
new.tree_depth = tree_depth
new.has_children = False
new.is_expanded = group.id() in self.expanded_groups
@@ -113,7 +111,6 @@ class EditGroup(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.edit_group"
bl_label = "Edit Group"
bl_options = {"REGISTER", "UNDO"}
copy_from_selector: bpy.props.BoolProperty(name="Copy from Selector", default=False)
def _execute(self, context):
props = context.scene.BIMGroupProperties
@@ -124,9 +121,6 @@ class EditGroup(bpy.types.Operator, tool.Ifc.Operator):
else:
attributes[attribute.name] = attribute.string_value
if self.copy_from_selector:
attributes["Description"] = context.scene.IFCSelector.selection_query
self.file = IfcStore.get_file()
ifcopenshell.api.run(
"group.edit_group", self.file, **{"group": self.file.by_id(props.active_group_id), "attributes": attributes}
@@ -242,31 +236,6 @@ class SelectGroupProducts(bpy.types.Operator, tool.Ifc.Operator):
return {"FINISHED"}
class UpdateGroup(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.update_group"
bl_label = "Update Group"
bl_options = {"REGISTER", "UNDO"}
query: bpy.props.StringProperty()
group_id: bpy.props.IntProperty()
def _execute(self, context):
self.file = IfcStore.get_file()
group = self.file.by_id(self.group_id)
query = self.query
new_products = Selector.parse(self.file, query)
ifcopenshell.api.run(
"group.update_group_products",
self.file,
**{
"group": group,
"products": new_products,
}
)
bpy.ops.bim.load_groups()
return {"FINISHED"}
class SelectGroupElements(bpy.types.Operator):
bl_idname = "bim.select_group_elements"
bl_label = "Select Group elements"
@@ -44,7 +44,6 @@ class ExpandedGroups(StrProperty):
class Group(PropertyGroup):
name: StringProperty(name="Name")
ifc_definition_id: IntProperty(name="IFC Definition ID")
selection_query: StringProperty(name="Selection Query")
is_expanded: BoolProperty(name="Is Expanded", default=False)
has_children: BoolProperty(name="Has Children", default=False)
tree_depth: IntProperty(name="Tree Depth")
@@ -131,7 +131,7 @@ class BIM_UL_groups(UIList):
else:
row.label(text="", icon="BLANK1")
row.label(text=f"*{item.name}") if item.selection_query != "" else row.label(text=item.name)
row.label(text=item.name)
group_id = item.ifc_definition_id
if context.scene.BIMGroupProperties.active_group_id == group_id:
op = row.operator("bim.select_group_products", text="", icon="RESTRICT_SELECT_OFF")
@@ -145,10 +145,6 @@ class BIM_UL_groups(UIList):
op.group = group_id
op = row.operator("bim.remove_group", text="", icon="X")
op.group = group_id
if item.selection_query != "":
op = row.operator("bim.update_group", text="", icon="FILE_REFRESH")
op.group_id = item.ifc_definition_id
op.query = item.selection_query
else:
op = row.operator("bim.select_group_products", text="", icon="RESTRICT_SELECT_OFF")
op.group = group_id
@@ -158,10 +154,6 @@ class BIM_UL_groups(UIList):
op.group = group_id
op = row.operator("bim.remove_group", text="", icon="X")
op.group = group_id
if item.selection_query != "":
op = row.operator("bim.update_group", text="", icon="FILE_REFRESH")
op.group_id = item.ifc_definition_id
op.query = item.selection_query
class BIM_UL_object_groups(UIList):
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import re
import bpy
import json
import ifcopenshell
@@ -24,10 +23,8 @@ import ifcopenshell.api
import ifcopenshell.guid
import ifcopenshell.util.element
import ifcopenshell.util.selector
from ifcopenshell.util.selector import Selector
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.group import ui
import blenderbim.core.search as core
from itertools import cycle
from bpy.types import PropertyGroup, Operator
@@ -19,12 +19,9 @@
import bpy
import blenderbim.tool as tool
from ifcopenshell import util
from ifcopenshell.util.selector import Selector
from blenderbim.bim.prop import ObjProperty, StrProperty, BIMFilterGroup
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.prop import ObjProperty, BIMFilterGroup
from blenderbim.bim.module.search.data import SearchData, ColourByPropertyData, SelectSimilarData
from bpy.types import PropertyGroup
from blenderbim.tool.ifc import Ifc
from . import ui, prop, operator
from bpy.props import (
PointerProperty,
-8
View File
@@ -1,10 +1,2 @@
def show_scene_elements(spatial):
spatial.show_scene_objects()
def search(search, spatial, query, action):
products = search.from_selector_query(query)
spatial.deselect_objects()
try:
spatial.filter_products(products, action)
except:
return "One or More Products could not be found because they are hidden in the ViewLayer"
+2 -2
View File
@@ -707,7 +707,7 @@ class Selector:
@interface
class Search:
def from_selector_query(cls, query): pass
pass
@interface
class Sequence:
@@ -831,7 +831,7 @@ class Spatial:
def can_reference(cls, structure, element): pass
def contract_container(cls, container): pass
def copy_xy(cls, src_obj, destination_obj): pass
def import_spatial_structure(cls, element, level_index): pass
def import_spatial_element(cls, element, level_index): pass
def deselect_objects(cls): pass
def disable_editing(cls, obj): pass
def duplicate_object_and_data(cls, obj): pass
-7
View File
@@ -2,10 +2,8 @@ import bpy
import json
import lark
import blenderbim.core.tool
import blenderbim.tool as tool
import ifcopenshell.guid
import ifcopenshell.util.selector
from ifcopenshell.util.selector import Selector
from blenderbim.bim.prop import BIMFacet
from typing import Union, Literal
@@ -115,11 +113,6 @@ class Search(blenderbim.core.tool.Search):
return value
return '"' + value.replace('"', '\\"') + '"'
@classmethod
def from_selector_query(cls, query: str) -> list[ifcopenshell.entity_instance]:
"""Returns a list of products from a selector query"""
return Selector().parse(tool.Ifc.get(), query)
class ImportFilterQueryTransformer(lark.Transformer):
def __init__(self, filter_groups):