From a3fd169bb6edf10ac1a3c3abc516f3490adbc6b5 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 23 Aug 2023 17:09:51 +1000 Subject: [PATCH] IfcPatch now uses the new facet selector syntax. --- src/ifcopenshell-python/docs/ifcpatch.rst | 4 ++-- src/ifcpatch/ifcpatch/recipes/ExtractElements.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ifcopenshell-python/docs/ifcpatch.rst b/src/ifcopenshell-python/docs/ifcpatch.rst index 7a296e4853..2923e2227c 100644 --- a/src/ifcopenshell-python/docs/ifcpatch.rst +++ b/src/ifcopenshell-python/docs/ifcpatch.rst @@ -47,7 +47,7 @@ In this example, we'll extract out all `IfcWall` elements. :: - $ ifcpatch -i input.ifc -o output.ifc -r ExtractElements -a ".IfcWall" + $ ifcpatch -i input.ifc -o output.ifc -r ExtractElements -a "IfcWall" $ cat output.ifc Here is a minimal example of how to use IfcPatch as a library: @@ -60,7 +60,7 @@ Here is a minimal example of how to use IfcPatch as a library: "input": "input.ifc", "file": ifcopenshell.open("input.ifc"), "recipe": "ExtractElements", - "arguments": [".IfcWall"], + "arguments": ["IfcWall"], }) ifcpatch.write(output, "output.ifc") diff --git a/src/ifcpatch/ifcpatch/recipes/ExtractElements.py b/src/ifcpatch/ifcpatch/recipes/ExtractElements.py index f21d2fd31d..fe1ced106e 100644 --- a/src/ifcpatch/ifcpatch/recipes/ExtractElements.py +++ b/src/ifcpatch/ifcpatch/recipes/ExtractElements.py @@ -37,13 +37,13 @@ class Patcher: .. code:: python # Extract all walls - ifcpatch.execute({"input": model, "recipe": "ExtractElements", "arguments": [".IfcWall"]}) + ifcpatch.execute({"input": model, "recipe": "ExtractElements", "arguments": ["IfcWall"]}) # Extract all slabs - ifcpatch.execute({"input": model, "recipe": "ExtractElements", "arguments": [".IfcSlab"]}) + ifcpatch.execute({"input": model, "recipe": "ExtractElements", "arguments": ["IfcSlab"]}) # Extract all walls and slabs - ifcpatch.execute({"input": model, "recipe": "ExtractElements", "arguments": [".IfcWall|.IfcSlab"]}) + ifcpatch.execute({"input": model, "recipe": "ExtractElements", "arguments": ["IfcWall, IfcSlab"]}) """ self.src = src self.file = file @@ -59,8 +59,7 @@ class Patcher: self.owner_history = self.new.add(owner_history) break self.add_element(self.file.by_type("IfcProject")[0]) - selector = ifcopenshell.util.selector.Selector() - for element in selector.parse(self.file, self.query): + for element in ifcopenshell.util.selector.filter_elements(self.file, self.query): self.add_element(element) self.create_spatial_tree() self.file = self.new