XbimEssentials icon indicating copy to clipboard operation
XbimEssentials copied to clipboard

Implement missing Partials in IFC4x3 schema

Open andyward opened this issue 11 months ago • 7 comments

A number of 'Partial' class extensions are missing from the IFC4x3 schema. E.g. IfcSitePartial, IfcCompoundPlaneAngleMeasurePartial etc.

Consider if these could be better implemented as extensions on the cross schema interfaces

andyward avatar Jan 30 '25 11:01 andyward

Hi,

while porting our application to support Ifc4x3, we encountered problems regarding Properties / Quantities. The IIfcObject interface fails to provide PhysicalSimpleQuantities / PropertySets / GetElementQuantity() ....

Trying to resolve queries for IIfcProperty, we tested the instance to specific IfcObject (Ifc2x3.Kernel / Xbim.Ifc4.Kernel / Xbim.Ifc4x3.Kernel) implementation, which seems not promising for future versions.

Do you have recommendations to resolve this issue?

WalchAndreas avatar Jan 31 '25 13:01 WalchAndreas

Naively we just need to implement (copy - paste) the Partial classes from IFC4 in IFC4x3 schema. E.g. For PhysicalSimpleQuantities etc in IFC4 & 2x3 we have these implemented as helper methods in IfcObjectPartial

But I actually think the better pattern (to save duplicating code) will be to implement as Extension-methods on the 'common' IFC4 interfaces so they can be defined once and used on all schemas. It may have made sense pragmatically to copy when we had 2 schemas but with 3+ it's feels like overhead.

You could even implement these ExtensionMethods yourself as a stop gap if it's blocking you - or send us a PR and we'll incorporate officially.

andyward avatar Jan 31 '25 18:01 andyward

Has this been resolved with your last commit?

Regarding GetPropertySets: This implementation relies on "IsDefinedBy" and returns all instance properties. To access the related ObjectType properties, the query "IsTypedBy" is necessary.

To show all Properties, these two queries have to be combined, while the instance properties should overrule the type properties.

Would it make sense to provide this query as an extension?

In the Ifc2x3 implementation, the Properties were queried by using the "IsDefinedByProperties" extensions. Is this equivalent to Ifc4.x?

WalchAndreas avatar Feb 03 '25 16:02 WalchAndreas

It's work in progress but feel free to try out. Aiming to get it into develop this week.

I was hoping to implement more through extension methods - but that will have to wait 'til C#14 since we need Extension properties to implement universally - plus it would be a breaking change. But I've generally tried to centralise the partial logic to we're re-using logic.

An extension method to get properties accounting for Type inheritance, and Instance override makes sense. I suspect we have one somewhere and just need to repurpose for cross-schema. However it's also potentially an expensive operation to coalesce this data so we'd need to be sure we don't impact simple use cases.

Regarding Ifc2x3s IsDefinedByProperties implementation being different: IFC4 changed the IsDefined relationship:

IFC4 CHANGE The data type has been changed from IfcRelDefines to IfcRelDefinesByProperties with upward compatibility for file based exchange.

So IsDefinedByProperties is technically redundant IFC4+ as it's the same as IsDefined. But we do need to check that when dealing with IFC2x3 cross-schema we're only looking at IfcReldefinesByProperties. Good spot.

andyward avatar Feb 04 '25 11:02 andyward

Hi,

while digging more into IfcObject in various versions, I stumbled over AddDefiningType, AddPropertySet, and AddQuantity (available for IFC2x3 and IFC4). This kind of functionality is missing in IFC4x3. Would it make sense to create/add an interface to access them generally?

Is there an intended way to write IfcObject creation for all schemas, to avoid code duplication? -> Just found Xbim.Ifc4.Interfaces.EntityCreator. Is this the correct way?

WalchAndreas avatar Feb 12 '25 12:02 WalchAndreas

while digging more into IfcObject in various versions, I stumbled over AddDefiningType, AddPropertySet, and AddQuantity (available for IFC2x3 and IFC4). This kind of functionality is missing in IFC4x3. Would it make sense to create/add an interface to access them generally?

Yes - that's what I've been doing with extension methods off the 'common' interface. E.g. IIfcObjectExtensions.cs

Examples in the tests here

(Because copy paste in the specific schemas is introducing these differences). This means any hypothetical Ifc4x4 gets the mechanics for free.

Is there an intended way to write IfcObject creation for all schemas, to avoid code duplication? -> Just found Xbim.Ifc4.Interfaces.EntityCreator. Is this the correct way?

Yes, EntityCreator is what you want for this. See my usage of it in the above IIfcObjectExtensions

Note currently this is a lowest common denominator approach - so only supports IFC2x3 entities. We're putting some thought into how to handle how you'd create say an IfcSensor (IFC4+) or IfcRoad (IFC4x3+) in a cross schema way.

andyward avatar Feb 13 '25 12:02 andyward

Mostly done but would like to centralise the Unit handling which is currently duplicated across the 3 schemas (with some subtle differences)

Remaining TODOs: mainly relate to New IFC4x3 features (and derived attributes)

Find all "TODO:", Regular expressions, Include external items, Current Project: Xbim.Ifc4x3\Xbim.Ifc4x3.csproj, "!*\bin\*;!*\obj\*;!*\.*\*"
XbimEssentials\Xbim.Ifc4x3\GeometricModelResource\IfcRevolvedAreaSolid.cs(82):// TODO: support other types of points. This is new in IFC4x3 RC2
XbimEssentials\Xbim.Ifc4x3\GeometryResource\IfcCartesianTransformationOperator2D.cs(41)://TODO: Implement getter for derived attribute U
XbimEssentials\Xbim.Ifc4x3\GeometryResource\IfcCartesianTransformationOperator3D.cs(63)://TODO: Implement getter for derived attribute U
XbimEssentials\Xbim.Ifc4x3\GeometryResource\IfcSurfaceCurve.cs(90)://TODO: Implement getter for derived attribute BasisSurface
XbimEssentials\Xbim.Ifc4x3\GeometryResource\IfcSurfaceOfRevolution.cs(65):// TODO: support other types of points. This is new in IFC4x3 RC2
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcLinearPlacement.cs(31)://TODO: Handle return of PlacementRelTo for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcLinearPlacement.cs(38)://TODO: Handle setting of PlacementRelTo for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcLinearPlacement.cs(51)://TODO: Handle return of Distance for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcLinearPlacement.cs(58)://TODO: Handle setting of Distance for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcLinearPlacement.cs(72)://TODO: Handle return of Orientation for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcLinearPlacement.cs(79)://TODO: Handle setting of Orientation for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcLinearPositioningElement.cs(31)://TODO: Handle return of Axis for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcLinearPositioningElement.cs(38)://TODO: Handle setting of Axis for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcOffsetCurveByDistances.cs(30)://TODO: Handle return of OffsetValues for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcReferent.cs(119)://TODO: Handle return of RestartDistance for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcReferent.cs(126)://TODO: Handle setting of RestartDistance for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcSectionedSolidHorizontal.cs(31)://TODO: Handle return of CrossSectionPositions for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcSectionedSolidHorizontal.cs(43)://TODO: Handle return of FixedAxisVertical for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4X1\IfcSectionedSolidHorizontal.cs(50)://TODO: Handle setting of FixedAxisVertical for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcFixedReferenceSweptAreaSolid.cs(44)://TODO: Handle return of StartParam for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcFixedReferenceSweptAreaSolid.cs(51)://TODO: Handle setting of StartParam for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcFixedReferenceSweptAreaSolid.cs(64)://TODO: Handle return of EndParam for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcFixedReferenceSweptAreaSolid.cs(71)://TODO: Handle setting of EndParam for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcPlacement.cs(30):// TODO: Martin- I assume this is the right approach?
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcPropertySetTemplate.cs(35)://TODO: Handle translation of PSET_MATERIALDRIVEN member from IfcPropertySetTemplateTypeEnum in property TemplateType
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcPropertySetTemplate.cs(44)://TODO: Handle translation of PSET_PROFILEDRIVEN member from IfcPropertySetTemplateTypeEnum in property TemplateType
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcRationalBSplineCurveWithKnots.cs(40)://TODO: Implement getter for derived attribute Weights in an interface
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcRationalBSplineSurfaceWithKnots.cs(39)://TODO: Implement getter for derived attribute Weights in an interface
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcRelDefinesByProperties.cs(65)://TODO: Handle setting of defined type IfcPropertySetDefinitionSet which is not a part of the target select interface IIfcPropertySetDefinitionSelect in property RelatingPropertyDefinition
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcRelInterferesElements.cs(30)://TODO: Handle return of RelatingElement for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcRelInterferesElements.cs(37)://TODO: Handle setting of RelatingElement for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcRelInterferesElements.cs(50)://TODO: Handle return of RelatedElement for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcRelInterferesElements.cs(57)://TODO: Handle setting of RelatedElement for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcRelInterferesElements.cs(101)://TODO: Handle return of ImpliedOrder for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcRelReferencedInSpatialStructure.cs(30)://TODO: Handle return of RelatedElements for which no match was found
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcSimplePropertyTemplate.cs(53)://TODO: Handle translation of Q_NUMBER member from IfcSimplePropertyTemplateTypeEnum in property TemplateType
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcSurfaceCurve.cs(94)://TODO: Implement getter for derived attribute BasisSurface in an interface
XbimEssentials\Xbim.Ifc4x3\Interfaces\IFC4\IfcSurfaceStyleRendering.cs(257)://TODO: Handle translation of PHYSICAL member from IfcReflectanceMethodEnum in property ReflectanceMethod
XbimEssentials\Xbim.Ifc4x3\MeasureResource\IfcUnitAssignmentPartial.cs(151):requiredUnit = null; // todo: not sure what to do here
XbimEssentials\Xbim.Ifc4x3\MeasureResource\IfcUnitAssignmentPartial.cs(153):requiredUnit = null; // todo: not sure what to do here
XbimEssentials\Xbim.Ifc4x3\MeasureResource\IfcUnitAssignmentPartial.cs(155):requiredUnit = null; // todo: not sure what to do here
XbimEssentials\Xbim.Ifc4x3\MeasureResource\IfcUnitAssignmentPartial.cs(163):requiredUnit = null; // todo: not sure what to do here
XbimEssentials\Xbim.Ifc4x3\MeasureResource\IfcUnitAssignmentPartial.cs(165):requiredUnit = null; // todo: not sure what to do here.
XbimEssentials\Xbim.Ifc4x3\MeasureResource\IfcUnitAssignmentPartial.cs(167):requiredUnit = null; // todo: not sure what to do here.
XbimEssentials\Xbim.Ifc4x3\MeasureResource\IfcUnitAssignmentPartial.cs(171):requiredUnit = null; // todo: not sure what to do here.
XbimEssentials\Xbim.Ifc4x3\MeasureResource\IfcUnitAssignmentPartial.cs(175):requiredUnit = null; // todo: not sure what to do here.
XbimEssentials\Xbim.Ifc4x3\MeasureResource\IfcUnitAssignmentPartial.cs(183):requiredUnit = null; // todo: not sure what to do here.
XbimEssentials\Xbim.Ifc4x3\ProfileResource\IfcMirroredProfileDef.cs(41)://TODO: Implement overriding derived attribute Operator getter

andyward avatar Mar 06 '25 11:03 andyward