XbimEssentials icon indicating copy to clipboard operation
XbimEssentials copied to clipboard

Can not distingguish ".U." and "$" on "IfcMaterialLayer.IsVentilated : OPTIONAL IfcLogical;"

Open highan911 opened this issue 2 years ago • 5 comments

When loading an IFC STEP file with data row like

#347= IFCMATERIALLAYER(#326,417.,.U.,'Component 1',$,$,$);

The corresponding property is "null" instance will be printed as

#347=IFCMATERIALLAYER(#326,417.,$,'Component 1',$,$,$);

The definition in "IFC4.exp" is

IsVentilated : OPTIONAL IfcLogical;

Assemblies and versions affected:

Issue found in Xbim.IO.MemoryModel 5.1.341 and relying on Xbim.Ifc4 5.1.341

Steps (or code) to reproduce the issue:

    string ifcPath = "./filename.ifc";
    MemoryModel model = MemoryModel.OpenReadStep21(ifcPath);
  
    var entity = model.Instances[347] as IIfcMaterialLayer;
  
    Console.WriteLine(entity.IsVentilated == null ? "null" : entity.IsVentilated.ToString());
  
    Console.WriteLine(entity.ToString());

Minimal file to reproduce the issue:

(Any IFC file with IFCMATERIALLAYER)

Expected behavior:

The property should be an "Xbim.Ifc4.MeasureResource.IfcLogical" with "_value==null"

highan911 avatar Apr 17 '23 11:04 highan911

There may be two cores to solve this issue.

The first core of this issue should be at StepP21Lex.lex line 35:

[\.][U][\.]	        {return((int)Tokens.NONDEF); } 

However, the second core is the interface IPropertyValue, which can not distinguish ".U." from "$" ... And if this interface is modified, a major number of classes will be affected ...

(Any good idea about this?)

highan911 avatar Apr 17 '23 12:04 highan911

Hi @highan911, I'm happy to have a look at this. Could you create a PR with a failing test, so I could start from there please?

martin1cerny avatar Apr 17 '23 15:04 martin1cerny

Hi @highan911, I'm happy to have a look at this. Could you create a PR with a failing test, so I could start from there please?

Thank you very much~

highan911 avatar Apr 17 '23 16:04 highan911

Appreciate this is old but having fixed up the GPLEX code, I had a quick look at this. As you say the issue is that IPropertyValue.BooleanVal returns a bool, and we use this interface when in the code-generated IPersist.Parse() methods such as in your IFCMATERIALLAYER example here

To fix this we'd need to:

  1. Extend the IPropertyValue interface with a LogicalVal property
  2. Regenerate (or spot fix) the Parse code for IfcLogical properties
  3. Update the lexer to output a new Token
  4. Map the token to a SetLogicalValue()
  5. Update the Parsers/Indexers to handle this new mechanic

... quite a bit of work (especially no 2 which needs @martin1cerny ). Semantically I'm not sure what the difference is between a null IfcLogical and an IfcLogical with value undefined.

andyward avatar Mar 28 '25 15:03 andyward

Appreciate this is old but having fixed up the GPLEX code, I had a quick look at this. As you say the issue is that IPropertyValue.BooleanVal returns a bool, and we use this interface when in the code-generated IPersist.Parse() methods such as in your IFCMATERIALLAYER example here

To fix this we'd need to:

  1. Extend the IPropertyValue interface with a LogicalVal property
  2. Regenerate (or spot fix) the Parse code for IfcLogical properties
  3. Update the lexer to output a new Token
  4. Map the token to a SetLogicalValue()
  5. Update the Parsers/Indexers to handle this new mechanic

... quite a bit of work (especially no 2 which needs @martin1cerny ). Semantically I'm not sure what the difference is between a null IfcLogical and an IfcLogical with value undefined.

Thank you for your response!

According to the buildingSMART IFC documentation, https://standards.buildingsmart.org/IFC/RELEASE/IFC4_1/FINAL/HTML/schema/ifcmaterialresource/lexical/ifcmateriallayer.htm

The description of this attribute says:

set to UNKNOWN if the material layer is an air gap and does not provide air exchange (or when this information about air exchange of the air gap is not available). set to FALSE if the material layer is a solid material layer (the default).

So the null value and the .U. value are semantically different.

I agree that this is quite a lot of work when I tried to fix it but end up realizing the modification on IPropertyValue will affect a lot.

I appreciate that this issue is finally on the TODO list, and hope for a good result : )

highan911 avatar Mar 31 '25 03:03 highan911