Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IFC Enums should default to NOTDEFINED rather than first defined enum #576

Open
andyward opened this issue Sep 5, 2024 · 0 comments
Open
Assignees

Comments

@andyward
Copy link
Member

andyward commented Sep 5, 2024

When we define an IFC Enum (such as IfcSlabTypeEnum) from code-gen, we define the enum values in the order they are in EXPRESS. e.g.

public enum IfcSlabTypeEnum : byte
{
	@FLOOR ,
	@ROOF ,
	@LANDING ,
	@BASESLAB ,
	@USERDEFINED ,
	@NOTDEFINED 
}

We're not specifying any integer values so the first enum will have a value of zero, and so becomes the implicit default. The net result is that any object with an enum like this will default to that first value, unless a value is set explicitly. Two examples of how this can happen:

  1. var slab = model.Instance.New<IfcSlabType>(); where slab.PredefinedType will default to FLOOR
  2. #1=IFCSLABTYPE('1hqIFTRjfV6AWq_bMtnZwI',$,$,$,$,$,$,$,$,$) where PredefinedType on the entity will also default to FLOOR, because the last parameter (PDT) is null

While both examples are technically invalid IFC, we still accept them, and will then report the type as being PredefinedType FLOOR. On different types it's obviously a different value, but still typically a value that would surprise.

Should we consider updating the codegen in a future release so any occurrence of 'NOTDEFINED' (or equivalent) will be the first in the Enum, meaning any default value would give conceptually accurate output. Obviously a breaking interface change so would need to align with a major release. Alternatively we need to initialise these Mandatory enum properties explicitly to an appropriate value.

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

No branches or pull requests

2 participants