IFC file freezes FreeCAD on import

This forum section is only for IFC-related issues
Post Reply
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

IFC file freezes FreeCAD on import

Post by bernd »

The attached ifc file has problems on ifc import. It seams the problems is in IfcOpenShell, see code later on. The reason why I'm gone post it here on the Forum anyway is FreeCAD freezes! I have to kill it with task manager. IMHO FreeCAD should not freeze if some other software has a problem.

Just open the file with FreeCAD. Screen of freeze is attached.


code to just import the problem shape:

Code: Select all

import ifcopenshell
from ifcopenshell import geom
settings = ifcopenshell.geom.settings()
settings.set(settings.USE_BREP_DATA,True)
settings.set(settings.SEW_SHELLS,True)
settings.set(settings.USE_WORLD_COORDS,True)
settings.set(settings.INCLUDE_CURVES,False)     # for stuct


file_path = 'C:\\Users\\BHA\\Desktop\\diversers\\3D--FC--diverse\\probleme_errors_nicht_im_forum\\building_modell_freecad_freezes.ifc'
f = ifcopenshell.open(file_path)
f.by_type('IfcPerson')


entity = f.by_id(18405)
print entity
cr = ifcopenshell.geom.create_shape(settings, entity)
# exception seams to be an IfcOpenShell problem !!!

'''
# not needed anymore because it has problems before
brep = cr.geometry.brep_data
print brep

import Part
shape = Part.Shape()
shape.importBrepFromString(brep)
Part.show(shape)
'''



output for me:

Code: Select all

Python 2.7.8 (default, Nov 17 2014, 20:37:05) [MSC v.1800 64 bit (AMD64)] on win32
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> import ifcopenshell
>>> from ifcopenshell import geom
>>> settings = ifcopenshell.geom.settings()
>>> settings.set(settings.USE_BREP_DATA,True)
>>> settings.set(settings.SEW_SHELLS,True)
>>> settings.set(settings.USE_WORLD_COORDS,True)
>>> settings.set(settings.INCLUDE_CURVES,False)     # for stuct
>>> 
>>> 
>>> file_path = 'C:\\Users\\BHA\\Desktop\\diversers\\3D--FC--diverse\\probleme_errors_nicht_im_forum\\building_modell_freecad_freezes.ifc'
>>> f = ifcopenshell.open(file_path)
>>> f.by_type('IfcPerson')
[#5=IfcPerson($,'Nicht definiert',$,$,$,$,$,(#1))]
>>> 
>>> 
>>> entity = f.by_id(18405)
>>> print entity
#18405=IfcWall('0s3v$ll25A$uYnr5AiVDst',#22,'Wand-081',$,$,#18125,#18401,'360F9FEF-BC21-4AFF-88B1-D452AC7CDDB7')
>>> cr = ifcopenshell.geom.create_shape(settings, entity)
>>> cr = ifcopenshell.geom.create_shape(settings, entity)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\0_BHA_privat\progr\FreeCAD_0.17.xxxxx_x64_dev_win\bin\lib\site-packages\ifcopenshell\geom\__init__.py", line 77, in create_shape
    repr.wrapped_data if repr is not None else None
RuntimeError: Failed to process shape
>>> 

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12324 (Git)
Build type: Release
Branch: master
Hash: 81e2480ca62c48b992db6e438cc69640a5166631
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: German/Switzerland (de_CH)


building_modell_freecad_freezes.zip
(261.68 KiB) Downloaded 69 times


freeze.jpg
freeze.jpg (525.12 KiB) Viewed 2814 times
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC file freezes FreeCAD on import

Post by bernd »

Just tested with uptodate IfcOpenShell (https://github.com/IfcOpenShell/IfcOpen ... t/33220fa7) outside FreeCAD and it returns some brep. Seams the problem is fixed in newer IfcOpenShell. Anyway FreeCAD should not freeze ...
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC file freezes FreeCAD on import

Post by bernd »

Just tested on Debian Jessi too. I have not the newest IfcOpenShell there, but a newer than on Windows dev download. On Jessie it imports fine too.

Can someone on Windows confirm the freeze?
thschrader
Veteran
Posts: 3158
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: IFC file freezes FreeCAD on import

Post by thschrader »

bernd wrote: Thu Oct 19, 2017 11:06 am Can someone on Windows confirm the freeze?
Yes, FC freezes. I can change the workbenches, thats the only reaction.
No other GUI-input possible. Must terminate FC with task-manager.
System:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12396 (Git)
Build type: Release
Branch: master
Hash: fb2b9d6cef287d826a905b90928d41a03e38d928
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: German/Germany (de_DE)
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC file freezes FreeCAD on import

Post by bernd »

found a workaround ...

if this junk of code
https://github.com/FreeCAD/FreeCAD/blob ... #L558-L562

Code: Select all

        try:
            cr = ifcopenshell.geom.create_shape(settings,product)
            brep = cr.geometry.brep_data
        except:
            pass # IfcOpenShell will yield an error if a given product has no shape, but we don't care

is replaced with:

Code: Select all

        try:
            cr = ifcopenshell.geom.create_shape(settings,product)
        except:
            pass # IfcOpenShell will yield an error if a given product has no shape, but we don't care
        try:
            brep = cr.geometry.brep_data
        except:
            pass # FreeCAD might freeze if IfcOpenShell fails because of bad IFC-geometry at ifcopenshell.geom.create_shape(settings,product)
I get around the freeze. The file still has some problem on a 2D shape, but this is another story ...

@Yorik and others:
Does someone know why FreeCAD freezes if the statements are in one try except?
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC file freezes FreeCAD on import

Post by bernd »

the work around from the last post only works in rare cases ... I'm a bit lost ... The problematic piece of code is inside an try exception but FreeCAD freezes anyway ?!? bernd
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC file freezes FreeCAD on import

Post by bernd »

BTW: to only try to import the bad shape and freeze FreeCAD one could use Python too:

Code: Select all

import importIFC
file_path = 'C:\\Users\\BHA\\Desktop\\building_modell_freecad_freezes.ifc'
skip =[]
only = [18405]
importIFC.insert(file_path, 'MyNewImportDoc', skip, only)
EDIT: see next post, with Python it works ...
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC file freezes FreeCAD on import

Post by bernd »

I am a step further! If Python is used to import the file from the first ppost, FreeCAD does not freeze !

Code: Select all

import importIFC
file_path = 'C:\\Users\\BHA\\Desktop\\diversers\\3D--FC--diverse\\probleme_errors_nicht_im_forum\\building_modell_freecad_freezes.ifc'
importIFC.insert(file_path, 'MyNewImportDoc')


If the GUI is used to import the file FreeCAD freezes.
freeze.jpg
freeze.jpg (232.16 KiB) Viewed 2682 times

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12431 (Git)
Build type: Release
Branch: master
Hash: c397aee9ed3efcb2e33fa719313c98cc4867cf32
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: German/Switzerland (de_CH)
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: IFC file freezes FreeCAD on import

Post by yorik »

In your last example, using python means in no-GUI FreeCAD, or inside the FreeCAD GUI but from the python console? In any case indeed this should not freeze freecad. The problem usually is that the embedded app (IfcOpenShell in this case) doesn't properly raise an error, but freezes or crashes, which makes it hard to handle on our part. But I'll have a look at this file too.

We could in any case add your change to the try/except block, as a workaround while we don't know the real cause...
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: IFC file freezes FreeCAD on import

Post by bernd »

The try exept workaround sems not to work in any case. With python I mean in FreeCAD GUI but in Python, but it does also not work in any case. Iwill have a closer look at this too. I hove a few similar files but they are huge and I can not share them here. But if we gone fix the one I posted we will make a big step.

Or we go the other way around and update IfcOpenShell on win?!

The only save way without freeze at all I have found so far, is to use the python for only import one shape from my first post. In this case the try except from importIFC works and FreeCAD never freezes.
Post Reply