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

Method __call__

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

Source from the content-addressed store, hash-verified

679 )
680
681 def __call__(self, inst: ifcopenshell.entity_instance, logger: Optional[Logger] = None) -> PropertyResult:
682 if isinstance(self.propertySet, str):
683 pset = get_pset(inst, self.propertySet)
684 psets = {self.propertySet: pset} if pset else {}
685 else:
686 all_psets = get_psets(inst)
687 psets = {k: v for k, v in all_psets.items() if k == self.propertySet}
688
689 is_pass = bool(psets)
690 reason = None
691
692 if not is_pass:
693 if self.cardinality == "optional":
694 return PropertyResult(True)
695 reason = {"type": "NOPSET"}
696
697 if is_pass:
698 props = {}
699 for pset_name, pset_props in psets.items():
700 props[pset_name] = {}
701 if isinstance(self.baseName, str):
702 prop = pset_props.get(self.baseName)
703 if prop == "UNKNOWN" and next(
704 p
705 for p in self.get_properties(inst.wrapped_data.file.by_id(pset_props["id"]))
706 if p.Name == self.baseName
707 ).NominalValue.is_a("IfcLogical"):
708 pass
709 elif prop is not None and prop != "":
710 props[pset_name][self.baseName] = prop
711 else:
712 props[pset_name] = {
713 k: v for k, v in pset_props.items() if k == self.baseName and v is not None and v != ""
714 }
715
716 if not bool(props[pset_name]):
717 if self.cardinality == "optional":
718 return PropertyResult(True)
719 is_pass = False
720 reason = {"type": "NOVALUE"}
721 break
722
723 pset_entity = inst.wrapped_data.file.by_id(pset_props["id"])
724
725 is_property_supported_class = True
726 for prop_entity in self.get_properties(pset_entity):
727 if prop_entity.Name not in props[pset_name].keys():
728 continue
729 if not isinstance(prop_entity, ifcopenshell.entity_instance):
730 # Predefined properties are special :(
731 pass
732 elif prop_entity.is_a("IfcPropertySingleValue"):
733 data_type = prop_entity.NominalValue.is_a()
734
735 if self.dataType and data_type.lower() != self.dataType.lower():
736 is_pass = False
737 reason = {"type": "DATATYPE", "actual": data_type, "dataType": self.dataType}
738 break

Callers

nothing calls this directly

Calls 15

get_propertiesMethod · 0.95
PropertyResultClass · 0.85
cast_to_valueFunction · 0.85
lowerMethod · 0.80
valuesMethod · 0.80
get_psetFunction · 0.70
get_psetsFunction · 0.70
is_xFunction · 0.70
itemsMethod · 0.45
getMethod · 0.45
is_aMethod · 0.45
by_idMethod · 0.45

Tested by

no test coverage detected