[HELP] How to export a equipment model to IFC

Hi,

I would like to design simple equipment models to create a IFC library (furniture, electric machinery, etc.).
I can’t figure out how to correctly export it to IFC, even a simple WB Part cube… I always get:

wstring_convert: to_bytes error

This is the report log:

10:41:35  Traceback (most recent call last):
  File "<string>", line 7, in <module>
  File "/Applications/FreeCAD-asm3-Daily-20210615.app/Contents/Resources/Mod/Arch/exportIFC.py", line 1550, in export
    ifcfile.write(filename)
  File "/Applications/FreeCAD-asm3-Daily-20210615.app/Contents/Resources/lib/python3.9/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 1595, in write
    return _ifcopenshell_wrapper.file_write(self, fn)
<class 'RuntimeError'>: wstring_convert: to_bytes error

If I test @Yorik house in his FreeCAD manual, everything goes fine and I get a IFC, but not if I try to model something by myself.
Is there any tutorial about how to create this simple components and successfully export them as IFC?
This is my cube test:
cube_v01.FCStd (23.3 KB)
Thanks

I am able to export the Site in your file after entering a value for the Address property and the Postal Code property.

OS: Windows 8.1 (6.3)
Word size of FreeCAD: 64-bit
Version: 0.20.25065 (Git)
Build type: Release
Branch: master
Hash: 4de2ad46b2b9c78ac2721a0dbea7c19306261095
Python version: 3.8.10
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: Dutch/Netherlands (nl_NL)

ifc-equipment.png

Any value in Address and Postal Code property or should it be formatted somehow?
You select the Site element and then export?
Do you have any special setup in Preferences/Import-Export/IFC export panel?

Could I get your modified FCstd file to test it here?

Thanks

Just random input.


Yes.


See image.
ifc-equipment-settings.png
cube_v01_roy.FCStd (21.6 KB)

Error persists here with your file and same exporting Preferences as you…

Here is my setup:

OS: macOS Mojave (10.14)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 2021.615.24301 +3747 (Git)
Build type: Release
Branch: LinkDaily
Hash: ecbfba008c481db4cb17bf8bd514b2d12690a8e5
Python version: 3.9.4
Qt version: 5.12.9
Coin version: 4.0.1
OCC version: 7.5.2
Locale: C/Default (C)

Also tried with:

OS: macOS Mojave (10.14)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: (HEAD detached at 0.19.1)
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.8
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)

and same error:

09:07:07  Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/Applications/FreeCAD_0.19-24276.app/Contents/Resources/Mod/Arch/exportIFC.py", line 1550, in export
    ifcfile.write(filename)
  File "/Applications/FreeCAD_0.19-24276.app/Contents/Resources/lib/python3.8/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 1458, in write
    return _ifcopenshell_wrapper.file_write(self, fn)
<class 'RuntimeError'>: wstring_convert: to_bytes error

Any other ideas?

Thanks

works without any problem. file from the first post


doc = FreeCAD.openDocument('C:/Users/BHA/Desktop/cube_v01.FCStd')
import exportIFC
prefs = {
    "DEBUG": True,
    "CREATE_CLONES": False,
    "FORCE_BREP": False,
    "STORE_UID": True,
    "SERIALIZE": False,
    "EXPORT_2D": True,
    "FULL_PARAMETRIC": False,
    "ADD_DEFAULT_SITE": False,
    "ADD_DEFAULT_BUILDING": True,
    "ADD_DEFAULT_STOREY": False,
    "IFC_UNIT": "metre",
    "SCALE_FACTOR": 0.001,
    "GET_STANDARD": False,
    "EXPORT_MODEL": "arch",
    "SCHEMA": "IFC2X3",
}
exportIFC.export([doc.Project], "C:/Users/BHA/Desktop/cube_v01.ifc", preferences=prefs)

OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 0.20.25220 (Git)
Build type: Release
Branch: master
Hash: 46282db7c8c65d1205a4cd03499d4beadb1573c6
Python version: 3.8.10
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: German/Switzerland (de_CH)

try this build https://github.com/FreeCAD/FreeCAD-Bundle/releases/tag/weekly-builds

BTW: us the pref “FORCE_BREP” set to False could lead to corrupt geometry. We have seen various problems with this setting. If set to True you should not get any problem if your geometry has no errors in FreeCAD.

I still get the same error, even with the build you share with me…

16:42:50  Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/Applications/FreeCAD_weekly-builds-25220.app/Contents/Resources/Mod/Arch/exportIFC.py", line 1550, in export
    ifcfile.write(filename)
  File "/Applications/FreeCAD_weekly-builds-25220.app/Contents/Resources/lib/python3.9/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 1595, in write
    return _ifcopenshell_wrapper.file_write(self, fn)
<class 'RuntimeError'>: wstring_convert: to_bytes error

OS: macOS Mojave (10.14)
Word size of FreeCAD: 64-bit
Version: 0.20.25220 (Git)
Build type: Release
Branch: master
Hash: 46282db7c8c65d1205a4cd03499d4beadb1573c6
Python version: 3.9.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: C/Default (C)

I have tried in a fresh Windows 10 FreeCAD 0.19 build and it worked fine without errors:

OS: Windows 10 Version 1909
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Spanish/Spain (es_ES)

It has to be something related with macOS…