← Back

mybimapi/validate_attributes

This function validates an IFC SPF (Step Physical File) model and returns a structured list of validation results for the individual instances in the file. In practical terms, it checks whether each line in the population is populated in a way that conforms to the IFC schema. For example, an instance such as #42=IFCWALL(...) may be flagged if it omits a required attribute, uses a value of the wrong kind, or points to an invalid kind of referenced object. A missing required owner history, a string placed where an entity reference is expected, or an invalid enumeration literal such as .FOO. where only values like .USERDEFINED. or .NOTDEFINED. are allowed are all typical examples of issues that can be reported. The result is therefore useful as a model-oriented QA report rather than just a parse success indicator.

The validation covers the correctness of attribute values as they appear in the IFC SPF population. Attributes must be present when required. In SPF syntax this corresponds to the distinction between $ and *: $ means that no value is supplied, while * marks a derived attribute position. For example, if a required attribute in #100=IFCPROPERTYSINGLEVALUE('FireRating',$,$,$); is left as $, that is a schema violation unless the attribute is defined as optional.

The checks also ensure that abstract entities are not instantiated, so a line using an abstract supertype directly would be invalid even if its argument list looks structurally correct. Inverse relationships are also checked against their cardinality rules, so if an entity is required to participate in at least one inverse relation but none exist, that is reported as well.

The validator checks that every supplied value matches the EXPRESS type declared for its attribute. This includes primitive values such as strings, integers, reals, booleans, logical values, and enumerations, as well as entity references, select types, and declared types. For instance, a numeric attribute expecting an integer should not receive a quoted string such as '12', and a reference-valued attribute should not receive a literal number where #25 is expected. Enumerations must use one of the schema-defined literals, so a value such as .ELEMENT. may be valid in one context while .SOMETHINGELSE. is not. Aggregate-valued attributes such as lists, sets, bags, and arrays are validated recursively. For example, if an attribute expects a list with at least one item, then () is invalid, while (#12,#13,#14) may be valid if each referenced item is of the correct type. Likewise, if an attribute expects a list of labels, then ('A','B','C') is acceptable in principle, but ('A',#42,'C') would fail because one member has the wrong type.

In addition to per-attribute checks, the validation also covers important model-wide consistency conditions. Identifier values such as GlobalId are checked for uniqueness and valid IFC GUID encoding, so two different objects must not share the same compressed GUID, and a malformed 22-character GUID may be reported even if the rest of the instance looks correct. Header content is also checked for conformance to expected structure and schema declarations.