IfcOpenShell_PythonWrapper icon indicating copy to clipboard operation
IfcOpenShell_PythonWrapper copied to clipboard

IfcOpenshell.open reads utf-8, but writes it differently making file unreadable.

Open Tmagga opened this issue 5 years ago • 2 comments

i've made a script that reads an .ifc file. then adds a pset and properties( i dont make any changes to the original, just add). And writes a new .ifc file that is a copy of the original+the additions. It works great until i get some utf-8 (or any spec char unicode)values. it reads and decodes it fine: (from notepad++)

2921= IFCBUILDINGELEMENTPROXYTYPE('3QPADpsq71CHeCe7e3GDm5',#32,'D\X2\00F8\X0\r',$,$,$,$,'DA64A373-DB41-C131-1A0C-A07A0340DC05',$,.NOTDEFINED.);

prints: Dør

but when its writing the file the same element get a diff unicode:

2921=IFCBUILDINGELEMENTPROXYTYPE('3QPADpsq71CHeCe7e3GDm5',#32,'D\X4\000000F8\X0\r',$,$,$,$,'DA64A373-DB41-C131-1A0C-A07A0340DC05',$,.NOTDEFINED.);

and the file is unreadable by the ifc utilizing software (Solibri MC).

is there any way of making IfcOpenshell write it with the same unicode as it reads? or can i force what encoding it should use when writing?

Tmagga avatar Aug 29 '19 08:08 Tmagga

I don't know if IfcOpenShell can be forced to use a specific encoding method (the shorter version saves some disk space) but "D\X4\000000F8\X0\r" to me seems a perfect representation of Dør, only the longer notation. Maybe also a Solibri issue?

Also see: https://standards.buildingsmart.org/documents/Implementation/IFC2x_Model_Implementation_Guide_V2-0b.pdf page 20

janbrouwer avatar Aug 30 '19 08:08 janbrouwer

is there any way of making IfcOpenshell write it with the same unicode as it reads? or can i force what encoding it should use when writing?

At the moment no.

Are you actually using this repository? There's five years of additional development here https://github.com/IfcOpenShell/IfcOpenShell/ Wouldn't solve the issue you're having. And I agree with @janbrouwer are you sure you're importing errors are due to the different encoding?

aothms avatar Sep 02 '19 11:09 aothms