mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
typing
This commit is contained in:
@@ -711,7 +711,9 @@ class FacetTransformer(lark.Transformer):
|
||||
|
||||
class Selector:
|
||||
@classmethod
|
||||
def parse(cls, ifc_file, query, elements=None):
|
||||
def parse(
|
||||
cls, ifc_file: ifcopenshell.file, query: str, elements: Optional[list[ifcopenshell.entity_instance]] = None
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
cls.file = ifc_file
|
||||
cls.elements = elements
|
||||
l = lark.Lark(
|
||||
|
||||
@@ -21,6 +21,7 @@ import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.selector as subject
|
||||
import ifcopenshell.util.placement
|
||||
import ifcopenshell.util.pset
|
||||
import numpy as np
|
||||
|
||||
|
||||
@@ -293,6 +294,10 @@ class TestSetElementValue(test.bootstrap.IFC4):
|
||||
|
||||
|
||||
class TestSelector(test.bootstrap.IFC4):
|
||||
def test_selecting_from_specified_elements(self):
|
||||
elements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") for _ in range(2)]
|
||||
assert subject.Selector.parse(self.file, ".IfcWall", elements[:1]) == [elements[0]]
|
||||
|
||||
def test_selecting_by_class(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
|
||||
Reference in New Issue
Block a user