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
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:
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…
>>> 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:
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)
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).
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.