ifc import error

This forum section is only for IFC-related issues
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: ifc import error

Postby yorik » Tue Sep 04, 2018 1:15 pm

Indeed there seems to be a problem with your version of IfcOpenShell. What puzzles me is that you are saying export works but import not? :?

Try running FreeCAD from a terminal, you might get more error message and hopefully a more exact location of the error...

"Unable to find header files" means it couldn't find OCC's .h files (the headers). These files usually are in the -dev packages and get installed in /usr/include (or, more and more, /usr/include/platformname) where platformname is for ex. x86_64-gnu-linux

So you need to check that you have these .h files (if you compile OCC/OCE yourself look into /usr/local/include instead, usually packages go in /usr and self-compiled stuff goes to /usr/local). Sometimes they are in a subdirectory, for ex. /usr/include/opencascade)

Then you need to inform cmake of the location of these files, this is easy to do with cmake-gui. Launch "cmake-gui ." from inside your build directory, search for OCC or OCE, and you'll find a variable like "OCC_INCLUDE_DIR" or something similar, that you need to point to your OCC include path.
cadgiru
Posts: 82
Joined: Thu Oct 27, 2016 9:53 am
Location: Norway
Contact:

Re: ifc import error

Postby cadgiru » Tue Sep 04, 2018 3:21 pm

yorik wrote:
Tue Sep 04, 2018 1:15 pm
Indeed there seems to be a problem with your version of IfcOpenShell. What puzzles me is that you are saying export works but import not? :?

Try running FreeCAD from a terminal, you might get more error message and hopefully a more exact location of the error...

"Unable to find header files" means it couldn't find OCC's .h files (the headers). These files usually are in the -dev packages and get installed in /usr/include (or, more and more, /usr/include/platformname) where platformname is for ex. x86_64-gnu-linux

So you need to check that you have these .h files (if you compile OCC/OCE yourself look into /usr/local/include instead, usually packages go in /usr and self-compiled stuff goes to /usr/local). Sometimes they are in a subdirectory, for ex. /usr/include/opencascade)

Then you need to inform cmake of the location of these files, this is easy to do with cmake-gui. Launch "cmake-gui ." from inside your build directory, search for OCC or OCE, and you'll find a variable like "OCC_INCLUDE_DIR" or something similar, that you need to point to your OCC include path.
ifcopenshell is installed from ifcopenshell-python27-master-9ad68db-linux64.zip to /usr/local/lib/python2.7/dist-packages/ifcopenshell

As stated export works, and exported files are imported without problems to anything I have thrown them at, except FreeCAD

Ran

Code: Select all

dpkg -l | grep -i opencascad
ii  liboce-foundation-dev:amd64            0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform library development files
ii  liboce-foundation11:amd64              0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform shared library
ii  liboce-modeling-dev:amd64              0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform library development files
ii  liboce-modeling11:amd64                0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform shared library
ii  liboce-ocaf-dev:amd64                  0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform library development files
ii  liboce-ocaf-lite-dev:amd64             0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform library development files
ii  liboce-ocaf-lite11:amd64               0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform shared library
ii  liboce-ocaf11:amd64                    0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform shared library
ii  liboce-visualization-dev:amd64         0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform library development files
ii  liboce-visualization11:amd64           0.18.2-2build1                           amd64        OpenCASCADE Community Edition CAE platform shared library
Next

Code: Select all

dpkg -L liboce-foundation11:amd64
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libTKMath.so.11.0.0
/usr/lib/x86_64-linux-gnu/libTKernel.so.11.0.0
/usr/share
/usr/share/doc
/usr/share/doc/liboce-foundation11
/usr/share/doc/liboce-foundation11/changelog.Debian.gz
/usr/share/doc/liboce-foundation11/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/liboce-foundation11
/usr/share/oce-0.18
/usr/share/oce-0.18/src
/usr/share/oce-0.18/src/OS
/usr/share/oce-0.18/src/OS/ApplicationFramework.tcl
/usr/share/oce-0.18/src/OS/DataExchange.tcl
/usr/share/oce-0.18/src/OS/Draw.tcl
/usr/share/oce-0.18/src/OS/FoundationClasses.tcl
/usr/share/oce-0.18/src/OS/ModelingAlgorithms.tcl
/usr/share/oce-0.18/src/OS/ModelingData.tcl
/usr/share/oce-0.18/src/OS/Modules.tcl
/usr/share/oce-0.18/src/OS/Visualization.tcl
/usr/share/oce-0.18/src/StdResource
/usr/share/oce-0.18/src/StdResource/CurrentUnits
/usr/share/oce-0.18/src/StdResource/MDTV-Standard.xwd
/usr/share/oce-0.18/src/StdResource/MDTVBaseUnits
/usr/share/oce-0.18/src/StdResource/MDTVCurrentUnits
/usr/share/oce-0.18/src/StdResource/MigrationSheet.txt
/usr/share/oce-0.18/src/StdResource/Plugin
/usr/share/oce-0.18/src/StdResource/Standard
/usr/share/oce-0.18/src/StdResource/Standard.us
/usr/share/oce-0.18/src/StdResource/StandardLite
/usr/share/oce-0.18/src/StdResource/TObj
/usr/share/oce-0.18/src/StdResource/XCAF
/usr/share/oce-0.18/src/UnitsAPI
/usr/share/oce-0.18/src/UnitsAPI/Lexi_Expr.dat
/usr/share/oce-0.18/src/UnitsAPI/Units.dat
/usr/lib/x86_64-linux-gnu/libTKMath.so.11
/usr/lib/x86_64-linux-gnu/libTKernel.so.11
This has happened on two different machines, first running Ubuntu 16.04 LTS and Xubuntu 16.04 LTS
Both have since been upgraded to Ubuntu 18.04 LTS and Xubuntu 18.04 LTS

FreeCAD has been installed from PPA, both stable and daily. This goes for both machines running the two flavours and versions of Linux.

Daily build is updated automatically. Same error has occured in all these situations.

Next :

Code: Select all

/usr/lib/freecad/bin/FreeCADCmd -l
FreeCAD 0.17, Libs: 0.17R13541 (Git)
(c) Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2018
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

[FreeCAD Console mode <Use Ctrl-D (i.e. EOF) to exit.>]
>>> 
What should I feed it? import some ifc?
What is the freecadCmd import ifc commandline

By the way still have a slight hunch about locale setting, only strange that FreeCAD seems to be the only program tested that will not import.
Reason for hunch is we have similar problems when import csv files to excel and other cad systems , especially with LC_NUMERIC=nb_NO.UTF-8 and
LC_NUMERIC=nb_NO.UTF-8 . They generally use , as decimal separator.

Code: Select all

peter@peter-HP-Z400-Workstation:~$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=nb_NO.UTF-8
LC_TIME=nb_NO.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=nb_NO.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=nb_NO.UTF-8
LC_NAME=nb_NO.UTF-8
LC_ADDRESS=nb_NO.UTF-8
LC_TELEPHONE=nb_NO.UTF-8
LC_MEASUREMENT=nb_NO.UTF-8
LC_IDENTIFICATION=nb_NO.UTF-8
LC_ALL=
also found this https://bugs.archlinux.org/task/4433

Maybe not, tried export LC_NUMERIC=en_GB.UTF-8 , Freecad still hangs on import ifc

regards
Last edited by cadgiru on Thu Sep 06, 2018 8:44 am, edited 2 times in total.
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: ifc import error

Postby yorik » Tue Sep 04, 2018 7:46 pm

cadgiru wrote:
Tue Sep 04, 2018 3:21 pm
[FreeCAD Console mode <Use Ctrl-D (i.e. EOF) to exit.>]
>>>
Try:

Code: Select all

import importIFC
importIFC.open("/path/to/an/ifcfile.ifc")
cadgiru
Posts: 82
Joined: Thu Oct 27, 2016 9:53 am
Location: Norway
Contact:

Re: ifc import error

Postby cadgiru » Thu Sep 06, 2018 6:46 am

yorik wrote:
Tue Sep 04, 2018 7:46 pm
cadgiru wrote:
Tue Sep 04, 2018 3:21 pm
[FreeCAD Console mode <Use Ctrl-D (i.e. EOF) to exit.>]
>>>
Try:

Code: Select all

import importIFC
importIFC.open("/path/to/an/ifcfile.ifc")

Code: Select all


$ /usr/lib/freecad/bin/FreeCADCmd -l
FreeCAD 0.17, Libs: 0.17R13541 (Git)
(c) Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2018
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

[FreeCAD Console mode <Use Ctrl-D (i.e. EOF) to exit.>]
>>> import importIFC
>>> importIFC.open("/home/peter/Documents/ifc/ArchDetail.ifc")
Importing IFC objects......
Reading BREP file......
Reading BREP file......
Geometry...
Geometry...
Geometry...
Geometry...
Geometry...
Geometry...
Reading BREP file......
Shapes...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/freecad/Mod/Arch/importIFC.py", line 336, in open
    doc = insert(filename,doc.Name,skip,only,root)
  File "/usr/lib/freecad/Mod/Arch/importIFC.py", line 627, in insert
    baseobj = FreeCAD.ActiveDocument.addObject("Part::Feature",name+"_body")
TypeError: argument 2 must be string without null bytes, not str
>>> import importIFC
>>> importIFC.open("/home/peter/Documents/ifc/Office_A_20110811.ifc")
Reading BREP file......
Reading BREP file......
Geometry...
Geometry...
Geometry...
Geometry...
Geometry...
Geometry...
Reading BREP file......
Shapes...
Traceback (most recent call last):				
  File "<stdin>", line 1, in <module>
  File "/usr/lib/freecad/Mod/Arch/importIFC.py", line 336, in open
    doc = insert(filename,doc.Name,skip,only,root)
  File "/usr/lib/freecad/Mod/Arch/importIFC.py", line 692, in insert
    a["IfcUID"] = str(guid)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)
>>> 
Tried with two different ifc files,
ArchDetail.ifc Exported from FreeCAD
Office_A_20110811.ifc Example from Building Smart

:oops:
Last edited by cadgiru on Thu Sep 06, 2018 8:46 am, edited 3 times in total.
chrisb
Posts: 17509
Joined: Tue Mar 17, 2015 9:14 am

Re: ifc import error

Postby chrisb » Thu Sep 06, 2018 7:56 am

cadgiru, readability is improved, if you put the output in code tags (as you did with your input), because it preserves indentation.
cadgiru
Posts: 82
Joined: Thu Oct 27, 2016 9:53 am
Location: Norway
Contact:

Re: ifc import error

Postby cadgiru » Sun Sep 09, 2018 6:48 am

chrisb wrote:
Thu Sep 06, 2018 7:56 am
cadgiru, readability is improved, if you put the output in code tags (as you did with your input), because it preserves indentation.
Maybe this should be moved to Arch. Looks like I am not the only one having challenges with ifcopenshell on Linux :oops: