Can anybody help in knowing whether IFC entity type names are case sensitive or case insensitive.
For example: Can we replace IFCPERSON
with IfcPerson
(camel case) or ifcperson
(small) in an *.ifc file?
Can anybody help in knowing whether IFC entity type names are case sensitive or case insensitive.
For example: Can we replace IFCPERSON
with IfcPerson
(camel case) or ifcperson
(small) in an *.ifc file?
How about applying the following convention in every single context:
Simply assume that they are case sensitive and work accordingly.
If you always do that, you will never have a problem.
If you see different casing examples, and all of them work, you can assume it is not case sensitive.
Otherwise, you will always be on the safe side if you simply follow the case conventions that you see and are proven.
Furthermore, you should always implement unit tests for every piece of functionality.
If you have questions about case sensitivity, implement unit tests to prove your assumptions right.
You might want to take a look at an online version of ISO10303-p21 which defines the STEP data format (file format of .ifc files).
Chapter 5.4 defines the format of tokens, to which entity names belong, to only contain uppercase letters and digits. So basically they are case sensitive, meaning they may only contain uppercase letters.
Let's look at how cases are defined in the standards for EXPRESS (used to specify the schema) and for STEP physical files (used for the actual *.ifc files).
According to ISO10303-11, in EXPRESS, entity names are case-insensitive. The grammar only mentions lower-case letters for entity identifiers (section 7.4 Identifiers and 7.1.2 Letters), reserving upper case for EXPRESS reserved words such as ENTITY
.
entity_head = ENTITY entity_id subsuper ";" .
entity_id = simple_id .
simple_id = letter { letter | digit | '_' }
letter = 'a' | 'b' | 'c' | ... | 'x' | 'y' | 'z'
So a schema can not define two different entity types that differ only by their case. In addition, the standard explicitly states case insensitivity:
EXPRESS uses the upper and lower case letters of the English alphabet [..] The case of letters is significant only within explicit string literals. NOTE - EXPRESS may be written using upper, lower, or mixed case letters [..].
Thus, the camel case you see in IFC-EXPRESS definitions (e.g. for IFC4) and in the corresponding BuildingSMART documentation is not significant and just chosen for the sake of readability.
When it comes to the STEP physical file encoding (ISO10303-21) and your actual instance files, the grammar mentions only upper case characters for entity types:
SIMPLE_ENTITY_INSTANCE = ENTITY_INSTANCE_NAME "=" SIMPLE_RECORD ";" .
SIMPLE_RECORD = KEYWORD "(" [ PARAMETER_LIST ] ")" .
KEYWORD = USER_DEFINED_KEYWORD | STANDARD_KEYWORD .
STANDARD_KEYWORD = UPPER { UPPER | DIGIT } .
UPPER = "A" | "B" | "C" | .. | "X" | "Y" | "Z" | "_" .
ISO10303-21 specifies further how to map the schema definition to the actual IFC file (section 12.2.). With regard to the encoding of entity type names it states that STEP files should only use upper case characters.
[..] In either case, any small letters shall be converted to their corresponding capital letters, i.e., the encoding shall not contain any small letters.
This also ensures case insensitivity, but in a different way than in EXPRESS.
Coming back to the original question, whether IFCPERSON
can be replaced with IfcPerson
. If you where to write the standard, you could use any case you like, since entity type names are case insensitive.
ENTITY IfcPerson;
If you are writing an IFC-STEP file, a strict interpretation of the standard would require to write entity type names in upper case.
#1 = IFCPERSON('ID', 'Last', 'First', $, $, $, $, $));
In practice, parsers have to rely on the case-insensitivity of the schema anyway. Thus, they will perform case-insensitive comparison to the schema-defined entity type names. Most likely they will accept mixed- or lower-case entity type names in the *.ifc file.
But a parser could also reject an IFC file with mixed-case entity type names as not standard-conforming or just ignore the entities which are not all-capital. Imagine an implementation that just converts the schema definitions to upper-case and then does a case-sensitive lookup for the entity instance types. This would be perfectly in accordance with the standard.