| 450 | |
| 451 | |
| 452 | class PartOf(Facet): |
| 453 | def __init__( |
| 454 | self, |
| 455 | name="IFCWALL", |
| 456 | predefinedType=None, |
| 457 | relation=None, |
| 458 | cardinality: Cardinality = "required", |
| 459 | instructions=None, |
| 460 | ): |
| 461 | self.parameters = ["name", "predefinedType", "@relation", "@cardinality", "@instructions"] |
| 462 | self.applicability_templates = [ |
| 463 | "An element with an {relation} relationship with an {name}", |
| 464 | "An element with an {relation} relationship", |
| 465 | ] |
| 466 | self.requirement_templates = [ |
| 467 | "An element must have an {relation} relationship with an {name} of predefined type {predefinedType}", |
| 468 | "An element must have an {relation} relationship with an {name}", |
| 469 | "An element must have an {relation} relationship", |
| 470 | ] |
| 471 | self.prohibited_templates = [ |
| 472 | "An element must not have an {relation} relationship with an {name}", |
| 473 | "An element must not have an {relation} relationship", |
| 474 | ] |
| 475 | super().__init__(name, predefinedType, relation, cardinality, instructions) |
| 476 | |
| 477 | def filter( |
| 478 | self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]] |
| 479 | ) -> list[ifcopenshell.entity_instance]: |
| 480 | if isinstance(elements, list): |
| 481 | return super().filter(ifc_file, elements) |
| 482 | return list(ifc_file) # Lazy |
| 483 | |
| 484 | def asdict(self, clause_type: str) -> dict[str, Any]: |
| 485 | results = super().asdict(clause_type) |
| 486 | entity = {} |
| 487 | if "name" in results: |
| 488 | entity["name"] = results["name"] |
| 489 | del results["name"] |
| 490 | if "predefinedType" in results: |
| 491 | entity["predefinedType"] = results["predefinedType"] |
| 492 | del results["predefinedType"] |
| 493 | if entity: |
| 494 | results["entity"] = entity |
| 495 | return results |
| 496 | |
| 497 | def parse(self, xml): |
| 498 | if "entity" in xml: |
| 499 | super().parse(xml["entity"]) |
| 500 | del xml["entity"] |
| 501 | return super().parse(xml) |
| 502 | |
| 503 | def __call__(self, inst: ifcopenshell.entity_instance, logger: Optional[Logger] = None) -> PartOfResult: |
| 504 | reason = None |
| 505 | if not self.relation: |
| 506 | is_pass = False |
| 507 | ancestors = [] |
| 508 | parent = self.get_parent(inst) |
| 509 | while parent: |
no outgoing calls