MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / __call__

Method __call__

src/ifctester/ifctester/facet.py:503–622  ·  view source on GitHub ↗
(self, inst: ifcopenshell.entity_instance, logger: Optional[Logger] = None)

Source from the content-addressed store, hash-verified

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:
510 ancestors.append(parent.is_a().upper())
511 if parent.is_a().upper() == self.name:
512 if self.predefinedType:
513 predefined_type = ifcopenshell.util.element.get_predefined_type(parent)
514 ancestors[-1] += f".{predefined_type}"
515 if predefined_type == self.predefinedType:
516 is_pass = True
517 else:
518 is_pass = True
519 break
520 parent = self.get_parent(parent)
521 if not is_pass:
522 reason = {"type": "ENTITY", "actual": ancestors}
523 elif self.relation == "IFCRELAGGREGATES":
524 aggregate = ifcopenshell.util.element.get_aggregate(inst)
525 is_pass = aggregate is not None
526 if not is_pass:
527 reason = {"type": "NOVALUE"}
528 if is_pass and self.name:
529 is_pass = False
530 ancestors = []
531 while aggregate is not None:
532 ancestors.append(aggregate.is_a().upper())
533 if aggregate.is_a().upper() == self.name:
534 if self.predefinedType:
535 predefined_type = ifcopenshell.util.element.get_predefined_type(aggregate)
536 ancestors[-1] += f".{predefined_type}"
537 if predefined_type == self.predefinedType:
538 is_pass = True
539 else:
540 is_pass = True
541 break
542 aggregate = ifcopenshell.util.element.get_aggregate(aggregate)
543 if not is_pass:
544 reason = {"type": "ENTITY", "actual": ancestors}
545 elif self.relation == "IFCRELASSIGNSTOGROUP":
546 group = None
547 for rel in getattr(inst, "HasAssignments", []) or []:
548 if rel.is_a("IfcRelAssignsToGroup"):
549 group = rel.RelatingGroup
550 break
551 is_pass = group is not None
552 if not is_pass:
553 reason = {"type": "NOVALUE"}
554 if is_pass and self.name:
555 if group.is_a().upper() != self.name:
556 is_pass = False
557 reason = {"type": "ENTITY", "actual": group.is_a().upper()}
558 if self.predefinedType:
559 predefined_type = ifcopenshell.util.element.get_predefined_type(group)
560 if predefined_type != self.predefinedType:

Callers

nothing calls this directly

Calls 7

get_parentMethod · 0.95
PartOfResultClass · 0.85
upperMethod · 0.80
get_predefined_typeMethod · 0.80
appendMethod · 0.45
is_aMethod · 0.45
get_containerMethod · 0.45

Tested by

no test coverage detected