FreeCAD does not import colors for IFC form Allplan

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

FreeCAD does not import colors for IFC form Allplan

Post by bernd »

Allplan has two exporter, attached a green column exported with each of the exporters. FreeCAD does not read the colors. Both are grey. I may have a look myself, but this will probably not happen before a release 0.18. To much to do in FEM ...

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15572 (Git)
Build type: Release
Branch: master
Hash: ab1f4c442d443adae106a2ea1ed877f33db86154
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Switzerland (de_CH)

gruen_new.ifc
(8.6 KiB) Downloaded 101 times
gruen_old.ifc
(5.58 KiB) Downloaded 115 times
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: FreeCAD does not import colors for IFC form Allplan

Post by yorik »

this file follows a scheme I hadn't seen before (the IfcStyledItem doesn't say which item it styles)... There is a quite complex system in that file, with drafting styles. We should open a mantis issue for this so we dont forget
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FreeCAD does not import colors for IFC form Allplan

Post by bernd »

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

Re: FreeCAD does not import colors for IFC form Allplan

Post by bernd »

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

Re: FreeCAD does not import colors for IFC form Allplan

Post by bernd »

git commit 2d1f6ab1a22 fixed the problem of the first post.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FreeCAD does not import colors for IFC form Allplan

Post by bernd »

new problems. If the new Allplan exporter and IFC4 is used the import breaks ...

Code: Select all

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22522 (Git)
Build type: Release
Branch: master
Hash: d8e476ef428017900dfe0f9359ba448503c216f9
Python version: 3.8.5
Qt version: 5.12.6
Coin version: 4.0.0
OCC version: 7.4.0
Locale: German/Switzerland (de_CH)

Code: Select all

14:19:45  Opening 'C:/Users/BHA/Desktop/new_exporter_IfC4.ifc'... done.
14:19:45  Building types and relationships table...
14:19:45  More than one 'Style' in 'IfcStyleItem', do nothing.
14:19:45  done.
14:19:45  Parsing 2 BIM objects...
14:19:45  1 / 2 object #89 : IfcSite (arch) no brep : Diverses 
14:19:45  2 / 2 object #166 : IfcColumn no layer found IfcColumn (arch) 2k 1 solids : Stuetze 
14:19:45  Processing Struct relationships...done
14:19:45  Processing Arch relationships...
14:19:45      adding 1 object(s) to Diverses
14:19:45      adding 1 object(s) to Project
14:19:45  Creating materials...Traceback (most recent call last):
  File "C:\0_BHA_privat\progr\FreeCAD_0.19.xxxxx-Win-Conda\Mod\Arch\ArchMaterial.py", line 297, in onChanged
    c = tuple([float(f) for f in obj.Material['DiffuseColor'].strip("()").strip("[]").split(",")])
  File "C:\0_BHA_privat\progr\FreeCAD_0.19.xxxxx-Win-Conda\Mod\Arch\ArchMaterial.py", line 297, in <listcomp>
    c = tuple([float(f) for f in obj.Material['DiffuseColor'].strip("()").strip("[]").split(",")])
<class 'ValueError'>: could not convert string to float: 'None'
14:19:45  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\0_BHA_privat\progr\FreeCAD_0.19.xxxxx-Win-Conda\Mod\Arch\importIFC.py", line 1303, in insert
    col = tuple([float(f) for f in string_color.strip("()").split(",")])
  File "C:\0_BHA_privat\progr\FreeCAD_0.19.xxxxx-Win-Conda\Mod\Arch\importIFC.py", line 1303, in <listcomp>
    col = tuple([float(f) for f in string_color.strip("()").split(",")])
<class 'ValueError'>: could not convert string to float: 'None'

new_exporter_IfC2x3.ifc
(6.04 KiB) Downloaded 82 times

new_exporter_IfC4.ifc
(5.99 KiB) Downloaded 83 times
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FreeCAD does not import colors for IFC form Allplan

Post by bernd »

the origin of the problem is a color table with None ectries: https://github.com/FreeCAD/FreeCAD/blob ... FC.py#L351

Eventually the color string is "None" which is impossible to be converted in a FreeCAD color. But it is intended to write None ... https://github.com/FreeCAD/FreeCAD/blob ... er.py#L375

Which means adaption here is needed: https://github.com/FreeCAD/FreeCAD/blob ... 1264-L1269 the None will be written into "DiffuseColor" attribute of material objects material dict.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FreeCAD does not import colors for IFC form Allplan

Post by bernd »

git commit 8292664f4943

colors for IFC4 export of Allplan are still not imported, because they all are None returned, but at least they do not break the import.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FreeCAD does not import colors for IFC form Allplan

Post by bernd »

https://github.com/FreeCAD/FreeCAD/blob ... er.py#L458

Code: Select all

# Never seen an IFC with more than one element in `Styles`
this is true for IFC2x3 but not for IFC4 ...

IFC2x3 example from above

Code: Select all

#116= IFCSTYLEDITEM(#97,(#107),$);
#107= IFCPRESENTATIONSTYLEASSIGNMENT((#109,#112));
#109= IFCCURVESTYLE($,#110,$,#111);
#112= IFCSURFACESTYLE('_hb_n_btl_be_beton_188',.BOTH.,(#114));


IFC4 example from above

Code: Select all

#141= IFCSTYLEDITEM(#131,(#143,#146),$);
#143= IFCCURVESTYLE($,#144,$,#145,$);
#146= IFCSURFACESTYLE('_hb_n_btl_be_beton_188',.BOTH.,(#148));
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FreeCAD does not import colors for IFC form Allplan

Post by bernd »

Post Reply