Skip to main content

I am trying to open an IFC file from a client but I keep getting a syntax error:

ISO10303-21: The input data file has a syntax error in instance '#105':
syntax error, unexpected P21_TOK_STD_KEYWORD, expecting ')'
ISO10303-21: Invalid file format, unable to continue reading
A fatal error has occurred. Check the logfile above for details

I looked up this element (#105) using Python ifcopenshell, and found that it is an IfcPostalAddress element. I've modified the content below so it is not the original address, but I have left in the word "États-Unis" (French for "United States), because I believe this is what is causing the syntax error.

"#105= IFCPOSTALADDRESS($,$,$,$,('123 Fake Street, Faketown, FS 01234 Ã\x89tats-Unis'),$,'','','','User Defined');\n"

I thought I would be able to fix it by re-encoding it to utf-8 and saving it appropriately (Python snippet below):

with open(out_file, "w", encoding="utf-8") as f_out:
    with open(in_file, encoding="latin1") as f_in:
        for line in f_in.readlines():
            f_out.write(line.encode("latin1").decode("utf-8"))

I checked the file afterwards and it seems to be intact, but with the correct characters.

 

But I still get the same error. I tried opening the file with both "IFC with Data Views" and "Industry Foundation Class STEP/XML Files (IFC)" Readers. The first one puts the Feature Types on the workspace but fails upon running. The second one fails before putting the Feature Types on the workspace.

 

Does anyone have any idea on what else I can try?

Hi @iboates​ ,

 

The following link specifies the correct method for including extended characters in IFC:

https://technical.buildingsmart.org/resources/ifcimplementationguidance/string-encoding/

 

In your case, the string should be:

  1. "#105= IFCPOSTALADDRESS($,$,$,$,('123 Fake Street, Faketown, FS 01234 \\X\\C9tats-Unis'),$,'','','','User Defined');\\n"

or:

  1. "#105= IFCPOSTALADDRESS($,$,$,$,('123 Fake Street, Faketown, FS 01234 \\X2\\00C9\\X0\\tats-Unis'),$,'','','','User Defined');\\n"

 

 


Hi @iboates​ ,

 

The following link specifies the correct method for including extended characters in IFC:

https://technical.buildingsmart.org/resources/ifcimplementationguidance/string-encoding/

 

In your case, the string should be:

  1. "#105= IFCPOSTALADDRESS($,$,$,$,('123 Fake Street, Faketown, FS 01234 \\X\\C9tats-Unis'),$,'','','','User Defined');\\n"

or:

  1. "#105= IFCPOSTALADDRESS($,$,$,$,('123 Fake Street, Faketown, FS 01234 \\X2\\00C9\\X0\\tats-Unis'),$,'','','','User Defined');\\n"

 

 

Thanks, that's it


Reply