| 180 | |
| 181 | |
| 182 | class Entity(Facet): |
| 183 | def __init__(self, name="IFCWALL", predefinedType=None, instructions=None): |
| 184 | self.parameters = ["name", "predefinedType", "@instructions"] |
| 185 | self.applicability_templates = [ |
| 186 | "All {name} data of type {predefinedType}", |
| 187 | "All {name} data", |
| 188 | ] |
| 189 | self.requirement_templates = [ |
| 190 | "Shall be {name} data of type {predefinedType}", |
| 191 | "Shall be {name} data", |
| 192 | ] |
| 193 | self.prohibited_templates = [ |
| 194 | "Shall not be {name} data of type {predefinedType}", |
| 195 | "Shall not be {name} data", |
| 196 | ] |
| 197 | super().__init__(name, predefinedType, instructions) |
| 198 | |
| 199 | def filter( |
| 200 | self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]] = None |
| 201 | ) -> list[ifcopenshell.entity_instance]: |
| 202 | if isinstance(elements, list): |
| 203 | return super().filter(ifc_file, elements) |
| 204 | |
| 205 | if isinstance(self.name, str): |
| 206 | try: |
| 207 | results = ifc_file.by_type(self.name, include_subtypes=False) |
| 208 | except: |
| 209 | # If the user has specified a class that doesn't exist in the version |
| 210 | results = [] |
| 211 | if not self.name.endswith("TYPE"): |
| 212 | try: |
| 213 | for element_type in ifc_file.by_type(f"{self.name}Type"): |
| 214 | results.extend(ifcopenshell.util.element.get_types(element_type)) |
| 215 | except: |
| 216 | pass |
| 217 | else: |
| 218 | results = [] |
| 219 | ifc_classes = [t for t in ifc_file.wrapped_data.types() if t.upper() == self.name] |
| 220 | for ifc_class in ifc_classes: |
| 221 | try: |
| 222 | results.extend(ifc_file.by_type(ifc_class, include_subtypes=False)) |
| 223 | except: |
| 224 | # If the user has specified a class that doesn't exist in the version |
| 225 | continue |
| 226 | if self.predefinedType: |
| 227 | return [r for r in results if self(r)] |
| 228 | return results |
| 229 | |
| 230 | def __call__(self, inst: ifcopenshell.entity_instance, logger: Optional[Logger] = None) -> EntityResult: |
| 231 | is_pass = inst.is_a().upper() == self.name |
| 232 | reason = None |
| 233 | |
| 234 | if ( |
| 235 | not is_pass |
| 236 | and inst.file.schema == "IFC2X3" |
| 237 | and not self.name.endswith("TYPE") |
| 238 | and (element_type := ifcopenshell.util.element.get_type(inst)) |
| 239 | ): |
no outgoing calls