ifcpatch.recipes.ExtractElements¶
Module Contents¶
- class ifcpatch.recipes.ExtractElements.Patcher(file: ifcopenshell.file, logger: logging.Logger | None = None, query: str = 'IfcWall', assume_asset_uniqueness_by_name: bool = False)¶
Bases:
ifcpatch.BasePatcherExtract certain elements into a new model
Extract a subset of elements from an existing IFC data set and save it to a new IFC file. For example, you might want to extract only the walls in a model and save it as a new model.
- Parameters:
query – A query to select the subset of IFC elements, using the ifcopenshell.util.selector.filter_elements grammar. Supports exclusion (blacklist) via ‘!’ on entity classes and ‘!=’ on attribute / pset / material / classification / location / group facets. Entity-class exclusion does not auto-seed from “all elements”, so a bare ‘! IfcSlab’ query returns nothing — start with a broad include (e.g. ‘IfcProduct’, ‘IfcElement’) and subtract from it.
assume_asset_uniqueness_by_name – Avoid adding assets (profiles, materials, styles) with the same name multiple times. Which helps in avoiding duplicated assets. —– Note that it assumes different project assets use different names (you can run IFC Assets Validation to confirm). If they’re not and this option is enabled, it may lead to confusing results (mixed up profiles, materials, styles). So either need to ensure assets naming is unique or disable this option.
Example:
# Extract all walls ifcpatch.execute({"input": "input.ifc", "file": model, "recipe": "ExtractElements", "arguments": ["IfcWall"]}) # Extract all slabs ifcpatch.execute({"input": "input.ifc", "file": model, "recipe": "ExtractElements", "arguments": ["IfcSlab"]}) # Extract all walls and slabs ifcpatch.execute({"input": "input.ifc", "file": model, "recipe": "ExtractElements", "arguments": ["IfcWall, IfcSlab"]}) # Extract everything except slabs (seed with a broad include, then subtract) ifcpatch.execute({"input": "input.ifc", "file": model, "recipe": "ExtractElements", "arguments": ["IfcProduct, ! IfcSlab"]}) # Extract walls whose Name is not "Foo" ifcpatch.execute({"input": "input.ifc", "file": model, "recipe": "ExtractElements", "arguments": ["IfcWall, attribute.Name != "Foo""]})
- add_decomposition_parents(element: ifcopenshell.entity_instance, new_element: ifcopenshell.entity_instance) None¶
element is IfcObjectDefinition
- add_element(element: ifcopenshell.entity_instance) None¶
- add_spatial_structures(element: ifcopenshell.entity_instance, new_element: ifcopenshell.entity_instance) None¶
element is IfcElement
- append_asset(element: ifcopenshell.entity_instance) ifcopenshell.entity_instance | None¶
- create_spatial_tree() None¶
- patch()¶
- assume_asset_uniqueness_by_name = False¶
- query = 'IfcWall'¶