[HELP] How to export a equipment model to IFC

This forum section is only for IFC-related issues
Post Reply
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

[HELP] How to export a equipment model to IFC

Post by pablogil »

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:

Code: Select all

wstring_convert: to_bytes error
This is the report log:

Code: Select all

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:
equipment.png
equipment.png (141.78 KiB) Viewed 8211 times
Thanks
Attachments
cube_v01.FCStd
(23.32 KiB) Downloaded 121 times
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [HELP] How to export a equipment model to IFC

Post by Roy_043 »

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

Code: Select all

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)
Attachments
ifc-equipment.png
ifc-equipment.png (11.81 KiB) Viewed 8171 times
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: [HELP] How to export a equipment model to IFC

Post by pablogil »

Roy_043 wrote: Thu Jul 08, 2021 1:31 pm I am able to export the Site in your file after entering a value for the Address property and the Postal Code property.
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
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [HELP] How to export a equipment model to IFC

Post by Roy_043 »

pablogil wrote: Thu Jul 08, 2021 2:36 pm Any value in Address and Postal Code property or should it be formatted somehow?
Just random input.

pablogil wrote: Thu Jul 08, 2021 2:36 pm You select the Site element and then export?
Yes.

pablogil wrote: Thu Jul 08, 2021 2:36 pm Do you have any special setup in Preferences/Import-Export/IFC export panel?
See image.
Attachments
ifc-equipment-settings.png
ifc-equipment-settings.png (46.14 KiB) Viewed 8138 times
cube_v01_roy.FCStd
(21.57 KiB) Downloaded 123 times
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: [HELP] How to export a equipment model to IFC

Post by pablogil »

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

Here is my setup:

Code: Select all

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:

Code: Select all

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:

Code: Select all

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?
yorik wrote: ping
Thanks
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: [HELP] How to export a equipment model to IFC

Post by bernd »

works without any problem. file from the first post

Code: Select all

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)
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: [HELP] How to export a equipment model to IFC

Post by bernd »

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

Re: [HELP] How to export a equipment model to IFC

Post by bernd »

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.
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: [HELP] How to export a equipment model to IFC

Post by pablogil »

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

Code: Select all

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)
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
pablogil
Posts: 881
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: [HELP] How to export a equipment model to IFC

Post by pablogil »

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...
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
Post Reply