Skip to content

ids: normalise Entity.filter() to always return a list - #9449

Open
RickBrice wants to merge 1 commit into
v0.9.0from
fix/ids-entity-filter-tuple-narrowing
Open

RickBrice wants to merge 1 commit into
v0.9.0from
fix/ids-entity-filter-tuple-narrowing

Conversation

@RickBrice

Copy link
Copy Markdown
Contributor

Entity.filter() returned ifc_file.by_type()'s result unmodified when no predefinedType was given. That result is not guaranteed to be a list (some ifcopenshell builds return a tuple), and every other facet's filter() decides whether to narrow the population handed to it, or discard it and rescan the entire model, based on isinstance(elements, list). A tuple fails that check, so the very next facet in an ids:applicability silently ignored the entity restriction and matched any class sharing the same attribute, classification, material, etc. value.

Observed in practice: a specification scoped to
entity(IFCMATERIAL) + attribute(Name=X) also matched an unrelated IfcTendonType that happened to share Name X with the IfcMaterial, failing the specification because the IfcTendonType lacks Pset_MaterialSteel.

Adds a regression test that forces by_type() to return a tuple so it reproduces independent of what the local ifcopenshell build normally returns.

An example is shown here:
IfcTester_Error

Attached are the source IFC file and the IDS. You may think the IDS is a bit weird (and it is). I am experimenting with creating an IDS that tests the outputs of a structural bridge design are retained in the IFC model as the model progresses through project development.

PGSuper_Import_Model.ifc.txt

PGSuper_Import_Model.ids.txt

Entity.filter() returned ifc_file.by_type()'s result unmodified when
no predefinedType was given. That result is not guaranteed to be a
list (some ifcopenshell builds return a tuple), and every other
facet's filter() decides whether to narrow the population handed to
it, or discard it and rescan the entire model, based on
isinstance(elements, list). A tuple fails that check, so the very
next facet in an <ids:applicability> silently ignored the entity
restriction and matched any class sharing the same attribute,
classification, material, etc. value.

Observed in practice: a specification scoped to
entity(IFCMATERIAL) + attribute(Name=X) also matched an unrelated
IfcTendonType that happened to share Name X with the IfcMaterial,
failing the specification because the IfcTendonType lacks
Pset_MaterialSteel.

Adds a regression test that forces by_type() to return a tuple so it
reproduces independent of what the local ifcopenshell build normally
returns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants