IfcOpenShell experimental serializer: how to use it?

This forum section is only for IFC-related issues
alafr
Posts: 31
Joined: Sat Jan 18, 2020 8:40 pm

IfcOpenShell experimental serializer: how to use it?

Postby alafr » Sun Feb 16, 2020 3:24 pm

Hi,
I can't get the IfcOpenShell serializer to work for IFC export.
According to the wiki:
However, IfcOpenShell v0.5 or above feature a serializer, which must be enabled in the Import/Export → IFC preferences. If enabled, this serializer is able to export very complex curved objects such as those based on NURBS, and thus avoid triangulated faces.
I have IfcOpenShell version 0.6.0b0 in my FreeCAD installation but if I activate the setting "Use IfcOpenShell serializer if available" in the IFC export preferences, and try to export a shape, I get this python exception:

Code: Select all

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "C:\Users\user\Downloads\FreeCAD_0.19.19591_x64_Conda_Py3QT5-WinVS2015\Mod\Arch\exportIFC.py", line 375, in export
    preferences=preferences
  File "C:\Users\user\Downloads\FreeCAD_0.19.19591_x64_Conda_Py3QT5-WinVS2015\Mod\Arch\exportIFC.py", line 1911, in getRepresentation
    p = geom.serialise(sh.exportBrepToString())
<class 'TypeError'>: _() missing 1 required positional argument: 'string'
I first ran into the issue when testing my pull request for fixing Arch Structure IFC export (see this other thread), but the problem is more general: I get the same exception even if I only select a simple Part Sphere primitive.

Is this IFC export broken or do I miss some kind of dependency/wrong setting?

Code: Select all

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19591 (Git)
Build type: Release
Branch: master
Hash: 27771fc6ee93170b6ecb978ff4da438a5b9cfe97
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Greek/Greece (el_GR)
User avatar
bernd
Posts: 11667
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: IfcOpenShell experimental serializer: how to use it?

Postby bernd » Sun Feb 16, 2020 6:34 pm

would you test ...

Code: Select all

import ifcopenshell
ifcopenshell.version
should give 0.6 !
User avatar
bernd
Posts: 11667
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: IfcOpenShell experimental serializer: how to use it?

Postby bernd » Sun Feb 16, 2020 6:42 pm

I can confirm ...

Code: Select all

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Arch/exportIFC.py", line 375, in export
    preferences=preferences
  File "/home/hugo/Documents/dev/freecad/freecadbhb_dev/build/Mod/Arch/exportIFC.py", line 1906, in getRepresentation
    p = geom.serialise(sh.exportBrepToString())
<class 'TypeError'>: _() missing 1 required positional argument: 'string'
on

OS: Debian GNU/Linux 10 (buster) (KDE//usr/share/xsessions/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19609 (Git)
Build type: Unknown
Branch: femtmp
Hash: a2eecf30596fdb9d9c16e18574279e67023c6c80
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Switzerland (de_CH)
User avatar
bernd
Posts: 11667
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: IfcOpenShell experimental serializer: how to use it?

Postby bernd » Sun Feb 16, 2020 6:55 pm

test in Python ...

Code: Select all

# make a new document

doc = App.ActiveDocument
co = doc.addObject("Part::Cone","Cone")
co.Radius1 = 200
co.Radius2 = 600
co.Height = 1000
doc.recompute()

sh = co.Shape.copy()
sh.Placement = co.getGlobalPlacement()
sh.scale(1000) # to meters


from ifcopenshell import geom
p = geom.serialise(sh.exportBrepToString())

Code: Select all

>>> 
>>> # make a new document
>>> 
>>> doc = App.ActiveDocument
>>> co = doc.addObject("Part::Cone","Cone")
>>> co.Radius1 = 200
>>> co.Radius2 = 600
>>> co.Height = 1000
>>> doc.recompute()
1
>>> 
>>> sh = co.Shape.copy()
>>> sh.Placement = co.getGlobalPlacement()
>>> sh.scale(1000) # to meters
<Solid object at 0x55a5c0e33c80>
>>> 
>>> 
>>> from ifcopenshell import geom
>>> p = geom.serialise(sh.exportBrepToString())
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: _() missing 1 required positional argument: 'string'
>>> 

https://github.com/FreeCAD/FreeCAD/blob ... C.py#L1906
alafr
Posts: 31
Joined: Sat Jan 18, 2020 8:40 pm

Re: IfcOpenShell experimental serializer: how to use it?

Postby alafr » Tue Feb 18, 2020 7:16 am

bernd wrote: Sun Feb 16, 2020 6:34 pm would you test ...
This is what I get for the version:

Code: Select all

>>> import ifcopenshell
>>> ifcopenshell.version
'0.6.0b0'
>>> 
And I get the exact same exception with your python test.

Apparently to syntax is geom.serialise(schema, string). I can't find any documentation however.

Code: Select all

>>> geom.serialise()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: _() missing 2 required positional arguments: 'schema' and 'string'
I installed Freecad 0.18 with ifcopenshell '0.5.0-dev' and it doesn't throw any exception. However, if I export the cone, the faces are triangulated. The option "Use IfcOpenShell serializer if available" doesn't seem to do anything...

Code: Select all

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.4 (GitTag)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 980bf9060e28555fecd9e3462f68ca74007b70f8
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Greek/Greece (el_GR)
User avatar
bernd
Posts: 11667
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: IfcOpenShell experimental serializer: how to use it?

Postby bernd » Tue Feb 18, 2020 8:09 pm

I have no idea how this serializer works. We need yorik or we need to ask at ifcopenshell forums directly.
User avatar
yorik
Site Admin
Posts: 12229
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: IfcOpenShell experimental serializer: how to use it?

Postby yorik » Tue Mar 03, 2020 2:05 pm

Sorry for the blackout guys!

The serializer normally works simply with giving it a Part shape, and it decides alone how to encode it in IFC. From what I have seen, it simply chooses between 2D geometry if there are no faces, IfcFacetedBrep if there are no NURBS surfaces (all flat faces with linear boundaries) or IfcAdvancedBrep in all other cases.

There is a long time I didn't test though, and I don't think many people use it outside of FreeCAD. By the look of the error, and the fact that IfcOpenShell 0.6 now works with multiple schemas, probably we now need to provide not only the Part shape but also the schema to use, that would make sense...
jahwobble
Posts: 51
Joined: Sat Sep 21, 2019 1:05 pm

Re: IfcOpenShell experimental serializer: how to use it?

Postby jahwobble » Sat Oct 10, 2020 10:53 pm

I'm getting the same error (<class 'TypeError'>: _() missing 1 required positional argument: 'string') when trying to export pipes to IFC. Walls work fine. Strangely, it worked fine with pipes a few days ago and I haven't installed any updates.
FCver.jpg
FCver.jpg (32.86 KiB) Viewed 614 times
User avatar
Kunda1
Posts: 10537
Joined: Thu Jan 05, 2017 9:03 pm

Re: IfcOpenShell experimental serializer: how to use it?

Postby Kunda1 » Sat Oct 10, 2020 10:59 pm

jahwobble wrote: Sat Oct 10, 2020 10:53 pm FCver.jpg
Please don't paste your About info, instead use the Copy to clipboard function that was intended just for this reason.

OS: Manjaro Linux (KDE//usr/share/xsessions/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22665 (Git) AppImage
Build type: Release
Branch: master
Hash: b0d7850406e046f3b7a8cd5da261e7d54df6bd99
Python version: 3.8.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)

Notice that you are behind, please update and report back if you can still recreate the issue. Thanks
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
jahwobble
Posts: 51
Joined: Sat Sep 21, 2019 1:05 pm

Re: IfcOpenShell experimental serializer: how to use it?

Postby jahwobble » Sun Oct 11, 2020 12:00 am

Please don't paste your About info, instead use the Copy to clipboard function that was intended just for this reason.
Sorry! Downloading...

Update: It works!
Last edited by jahwobble on Sun Oct 11, 2020 12:25 am, edited 1 time in total.