IFC import

Hi all
Not sure if this should be posted here, but here goes:

All my Linux machines are based on Ubuntu, they all give this error while importing:
utfFC.png
Currently I am setting up a new machine, a Dell Precision 3250.

It has windows 10 pro as installed OS.

I am in the process of installing Linux as my second OS. Linux is my preferred.

My testing of freecad is mainly centered around IFC workflow.

Can any of You please guide me to which:

  • LINUX and freecad version should I install to avoid the above issues?


  • Freecad version for testing IFC on Windows

The IFC import issue has bothered me for a long time, so any advice would be much appreciated

Best regards

This is strange… Can you share the problematic IFC file?

This is an old problem… Works on windows,
On Ubuntu based machines all ifc files cause the system to hang on import, this goes for both files exported from freecad and from others..
Looks very similar to https://forum.freecadweb.org/viewtopic.php?f=39&t=32158

regards

I think I had reported something similar but can’t find it at the moment…

…memory is not good, seems something related to python 2 / 3 and was fixed earlier…


Post your FC details.

Ah yes, UTF related…

It seems I have the exact same issue. Did you find the solution to this problem?

Hi,

same problem here.
It seems the same reported in:

https://forum.freecadweb.org/viewtopic.php?f=39&t=30451
https://forum.freecadweb.org/viewtopic.php?f=39&t=32158
https://forum.freecadweb.org/viewtopic.php?f=39&t=31163

When I try to import an IFC file (whatever IFC file) FC freeze and I need to kill the application.
If I try without the GUI the issue is located at the importIFC.py mod:

$ freecadcmd-daily -l
FreeCAD 0.18, Libs: 0.18R15860 (Git)
(c) Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2019
  #####                 ####  ###   #### 
  #                    #      # #   #   #
  #     ##  #### ####  #     #   #  #   #
  ####  # # #  # #  #  #     #####  #   #
  #     #   #### ####  #    #     # #   #
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

[FreeCAD Console mode <Use Ctrl-D (i.e. EOF) to exit.>]
>>> import importIFC
>>> importIFC.open("test.ifc")
Importing IFC objects......
Traceback (most recent call last):        (25.0 %)   
  File "<stdin>", line 1, in <module>
  File "/usr/lib/freecad-daily/Mod/Arch/importIFC.py", line 373, in open
    doc = insert(filename,doc.Name,skip,only,root)
  File "/usr/lib/freecad-daily/Mod/Arch/importIFC.py", line 848, in insert
    a["IfcUID"] = str(guid)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)
>>>

I’ve just compiled IfcOpenShell using the nix script (https://github.com/IfcOpenShell/IfcOpenShell/blob/master/nix/build-all.py) and I didn’t notice any error during the procedure.

These are my specs:

OS: Ubuntu 18.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15860 (Git)
Build type: Release
Branch: master
Hash: 3b708c7f84b0425076b520e1d95627b20fd75fe0
Python version: 2.7.15rc1
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)

I hope someone could help: FC it’s an amazing software and I’d like to use it for BIM but it’s a pity not to be able to work with IFC

two hints from my side …

  • make sure you gone use the same Python (Py2 or Py3) for FreeCAD and IfcOpenShell
  • does work ifcopenshell without FreeCAD- there are some ifcfiles in ifcopenshell sources included?

start python or python3

import ifcopenshell
f = ifcopenshell.open('ifcopenshellsources/test/input/acad2010_objects.ifc')
f.by_type('IfcPerson')
f.by_type('IfcWall')

For me on Debian Buster ifc import works on Python 2 and Python 3 with this file https://github.com/aothms/IfcOpenHouse

Yes, ifcopenshell works both on python2 and python3

$:~/Documents$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ifcopenshell
>>> f = ifcopenshell.open('lamp.ifc')
>>> f.by_type('IfcPerson')
[#4=IfcPerson($,'Maros','János',$,$,$,$,$)]
>>> g = ifcopenshell.open('wall.ifc')
>>> g.by_type('IfcWall')
[#36=IfcWall('3Y30_eCwGHwPsPuDLUGSGJ',#5,'Wall','',$,#33,#35,$)]
>>> 
$:~/Documents$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ifcopenshell
>>> f = ifcopenshell.open('lamp.ifc')
>>> f.by_type('IfcPerson')
[#4=IfcPerson($,'Maros','János',$,$,$,$,$)]
>>> g = ifcopenshell.open('wall.ifc')
>>> g.by_type('IfcWall')
[#36=IfcWall('3Y30_eCwGHwPsPuDLUGSGJ',#5,'Wall','',$,#33,#35,$)]
>>>

The lamp.ifc file is a lamp I downloaded from https://www.bimobject.com
The wall.ifc file (attached) is just a wall I modeled in freecad.
Both the files are imported without problem on Blender with the ifcblender addon
wall.ifc (2.54 KB)

This is a really strange error… the GUID of IFC elements is not supposed to contain non-ASCII characters…

I would be curious, if you could edit /usr/lib/freecad-daily/Mod/Arch/importIFC.py, and, just before the problematic line ( line 848, insert a[“IfcUID”] = str(guid)), add a line like this:

print(guid)

and run the import procedure again. So right before the error, we’ll see what that guid contains…

This is what I got:

>>> importIFC.open("wall.ifc")
Importing IFC objects......
����������������򀁇􀁷􀁳񀁵��������򠁇󙖠翈񭋐翈��������
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/freecad-daily/Mod/Arch/importIFC.py", line 373, in open
    doc = insert(filename,doc.Name,skip,only,root)
  File "/usr/lib/freecad-daily/Mod/Arch/importIFC.py", line 849, in insert
    a["IfcUID"] = str(guid)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)

I don’t think it’s normal…
What was it supposed to be?

Thanks for testing. Indeed this is not normal at all…
Each IFC object has a guid which is a unique text that identifies the object and looks like: 2Hm9JvZjohDNSD2kdxZI3b
It should only contain latin letters or numbers.

If you open the ifc file with a text editor, you’ll see that some entities have one, for ex:

#94= IFCRELDEFINESBYPROPERTIES('2Hm9JvZjohDNSD2kdxZI3b',#25,$,$,(#74),#89);

Apparently your file is okay, and doing it via python only in the console seems to work too… I don’t know what could be causing this problem :frowning:

Just as an afterthought, is your FreeCAD in english? If not, can you try by setting it in english, to see if it makes any difference?

Yes, thanks: my FreeCad is in English as well as the operating system (Ubuntu Gnome) it runs on.

I also installed IFC++ and its viewer works without problems.

I’m going to test it in a windows machine (a virtual one) to check if there is some difference. I’ll let you know about it.

I’m so perplexed :confused:

HI,
some updates about the issue:

I tried to import an IFC file in a Windows 7 machine. Actually I tried on two machine, a physical one and a virtual one (the last is hosted on Virtual box by one of the two Ubuntu machine I unsuccessfully used until now).

The FreeCAD version I used is the same (0.18.15969) but the result is very different:

  • on the physical machine I had no problem at all: the IFC file has been perfectly imported


  • on the virtual one the object seems correctly imported but as soon as the software load the data the GUI freezes (see the screenshot attached) and force me to kill the application. The console return this message:


Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation
Finished importing.

This are the specs for both machines (on the virtual machine I installed the image of the same Windows version):

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15969 (Git)
Build type: Release
Branch: master
Hash: 4765b7e2fe6d3609e9fbf3e3eb6648d7af1dd526
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)

Some suggestion about what to try next?
Screenshot from 2019-02-28 17-46-16.png

The last issue is because of bad OpenGL support on virtualbox… IIRC there is an experimental option somewhere to enable 3D inside the VM, but I have never tested…

Still don’t know what might be causing your first issue. It’s really weird

Solved!
I needed to recompile ifcopenshell but this time I followed the tutorial published on https://forum.freecadweb.org/viewtopic.php?f=39&t=17536
It’s important to note that in step 9 I had to use the version of python 2.7.12u rather than the 2.7.12 (the latter didn’t work).

Surely I did something wrong before (now I don’t remember exactly but I think I followed the instruction on the ifcopenshell github page), anyway I think that this procedure is not so easy for many people and it would be better if ifcopenshell was bundled somehow in the linux freecad version (for instance I had no problem at all with the windows version where ifcopenshell was immediately working).

Thanks again for your excellent job with freecad!

Just happen I need to recompile and find out exactky the 2.7.12 u forgot in my previous ost :smiley:

Thay u should stand for utf.


Glad you solve it !

Hurray! Glad you had it working.
Indeed ifcopenshell should be more easily usable. But bundling it with FreeCAD is a complex affair, specially on linux..
The best path would be that linux distributions would adopt it. @kkremitzki is working on packaging ifcopenshell for debian I think.. That would be an excellent thing.