IFC import fails in v0.19

This forum section is only for IFC-related issues
Post Reply
renatorivo
Veteran
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

IFC import fails in v0.19

Post by renatorivo »

When I import Yorik's House in version 0.19 FreeCAD crashes with this error
errore casayorik.PNG
errore casayorik.PNG (27.76 KiB) Viewed 2337 times
casayorik-bimvision.PNG
casayorik-bimvision.PNG (64.97 KiB) Viewed 2337 times
CasaYorik.ifc
(67.03 KiB) Downloaded 66 times
OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18644 (Git)
Build type: Release
Branch: master
Hash: 481870be2b48ef95b59acf1440b069d42b6fad23
Python version: 3.6.7
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)

Even importing other IFC files creates errors and fails. See https://forum.freecadweb.org/viewtopic.php?f=28&t=40576 ( Italian forum)
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC import fails in v0.19

Post by bernd »

run the following code in FreeCAD

Code: Select all

import ifcopenshell
ifcfile = "C:/Users/BHA/Downloads/CasaYorik.ifc"
f = ifcopenshell.open(ifcfile)
f.by_type('IfcProject')
ifcopenshell does not find a IfcProject and thus FreeCAD hangs. We should fix the crash in a first step.

Code: Select all

>>> 
>>> import ifcopenshell
>>> ifcfile = "C:/Users/BHA/Downloads/CasaYorik.ifc"
>>> f = ifcopenshell.open(ifcfile)
>>> f.by_type('IfcProject')
[]
>>> 
but if the file is opened in an editor there is a IfcProject

Code: Select all

#20=IFCPROJECT('d90775e9_7071_491c_a93',#5,'house',$,$,$,$,(#11),#19);
In a second step the question is, why does ifcopenshell does not find the IfcProject if there is one.

BTW: the file was exported with FreeCAD on 5th of march in 2016. Might be there is a problem with the file.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC import fails in v0.19

Post by bernd »

bernd wrote: Mon Nov 04, 2019 9:52 am ... ifcopenshell does not find a IfcProject and thus FreeCAD hangs. We should fix the crash in a first step. ...
git commit 64cf85c
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC import fails in v0.19

Post by bernd »

more informations. It seams IFC4 related ...

Attached two simple ifc exported from Allplan one is ifc2x3, one is ifc4. The ifc2x3 works great whereas for the ifc4 no IfcProject is found ...

Code: Select all

import ifcopenshell
ifcopenshell.open("C:/Users/BHA/Desktop/box_ifc2x3.ifc").by_type('IfcProject')
ifcopenshell.open("C:/Users/BHA/Desktop/box_ifc4.ifc").by_type('IfcProject')

Code: Select all

>>> 
>>> import ifcopenshell
>>> ifcopenshell.open("C:/Users/BHA/Desktop/box_ifc2x3.ifc").by_type('IfcProject')
[#35=IfcProject()]
>>> ifcopenshell.open("C:/Users/BHA/Desktop/box_ifc4.ifc").by_type('IfcProject')
[]
>>> 
box_ifc2x3.ifc
(7.86 KiB) Downloaded 76 times

box_ifc4.ifc
(7.75 KiB) Downloaded 81 times
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC import fails in v0.19

Post by bernd »

User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC import fails in v0.19

Post by bernd »

Code: Select all

import ifcopenshell
ifcopenshell.version
ifcopenshell.schema_identifier

Code: Select all

>>> ifcopenshell.version
'0.5.0-rc1'
>>> ifcopenshell.schema_identifier
'IFC2X3'
>>> 
 
In ifcopenshell 0.5 you only can parse one IFC version. The one included in FreeCAD is IFC2x3. If y IFC4 file is parsed with this it might work or might not work. It seams not to work.
User avatar
hlg
Posts: 39
Joined: Fri Jul 12, 2019 10:11 am

Re: IFC import fails in v0.19

Post by hlg »

Can you verify that this version of IFCOpenShell can actually handle IFC4? Earlier versions needed to be compiled for a specific IFC schema version, either IFC2x3 or IFC4. I believe the version included in releases is the one compiled for IFC2x3 so far. Try this to check:

Code: Select all

>>> import ifcopenshell
>>> ifcopenshell.schema_identifier
'IFC2X3'
>>> ifcopenshell.version
'0.5.0-dev'
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC import fails in v0.19

Post by bernd »

@hlg: cross post ... by the time you posted I edited my post ...

Just tested with ifcopenshell 0.6 which can handle IFC2x3 and IFC4 ...

Code: Select all

import ifcopenshell
ifcopenshell.version
>>> import ifcopenshell
>>> ifcopenshell.version
'0.6.0b0'

good news ...
Attachments
Screenshot_20191104_123400.png
Screenshot_20191104_123400.png (127.77 KiB) Viewed 2270 times
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC import fails in v0.19

Post by bernd »

find more informations in this regard here ... https://forum.freecadweb.org/viewtopic.php?p=311656
renatorivo
Veteran
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: IFC import fails in v0.19

Post by renatorivo »

Thanks!
Post Reply