xBimTeam / XbimEssentials

A .NET library to work with data in the IFC format. This is the core component of the Xbim Toolkit
https://xbimteam.github.io/
Other
477 stars 171 forks source link

Provide means of accessing PredefinedType values from super-classes/interfaces #546

Closed andyward closed 5 months ago

andyward commented 5 months ago

Xbim Essentials implements PredefinedType as a strongly typed enumeration on concrete schema classes. E.g. IfcSanitaryTerminalType.PredefinedType

This means you can't access the value from an ancestor class without casting to the concrete class.

This is problematic when building queries against super-classes of a collection of objects. e.g. filtering by IfcWall.IsTypedBy.RelatingType provides an ITypeObject, which you would expect to be an IfcWallType - but in many other cases the isTypedBy relationship is much more open.

A particular use case has come up in the xbim implementation of BuildingSMART IDS, where you may have a specification that wants to select all IfcFlowTerminals elements defined by a Type with a PredefinedType BATH or another enum from IfcSanitaryTerminalTypeEnum.

See https://github.com/buildingSMART/IDS/pull/240#pullrequestreview-1864768625 for more details. The set of possible types for IfcFlowTerminal.IsTypedBy is unconstrained. The existing solution to this would likely involve one of:

Another general solution in Essentials would be to provide support for accessing a string (or object) value from a base class in xbim such as:

public partial interface @IIfcObject : IIfcObjectDefinition
{
    // New Property 
    public abstract string PredefinedTypeValue { get; };
}

This could be implemented either in code-gen, partial classes, or generically using the ExpressMetadata and reflection

This would also need to be on IIfcTypeObject etc.