STEP Export/Import colors override (?)

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
andr.syn
Posts: 7
Joined: Thu Sep 09, 2021 8:01 pm

Re: STEP Export/Import colors override (?)

Post by andr.syn »

I will try, thank you.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP Export/Import colors override (?)

Post by easyw-fc »

andr.syn wrote: Fri Sep 10, 2021 10:26 pm I will try, thank you.
here is the issue: https://tracker.freecadweb.org/view.php?id=4744
andr.syn
Posts: 7
Joined: Thu Sep 09, 2021 8:01 pm

Re: STEP Export/Import colors override (?)

Post by andr.syn »

Thank you for adding a link here.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP Export/Import colors override (?)

Post by easyw-fc »

andr.syn wrote: Fri Sep 10, 2021 10:26 pm ping
I've added a note at the tracker:
https://tracker.freecadweb.org/view.php?id=4744#c15957

it could be related to OCC release version, not to FC version ...
[OCCT] 7.5.0 recently additions -> 0029902: Data Exchange, XCAF - provide extended Material definition for visualization purposes
0029902: Data Exchange, XCAF - provide extended Material definition for visualization purposes
Description XCAF defines a structure XCAFPrs_Style accumulating visual properties:
- Surface color and transparency, RGBA;
- Curve color, RGB;
- Hidden flag, Boolean.
https://tracker.dev.opencascade.org/view.php?id=29902

EDIT:
if we can fix this, we could also add the transparency property to import/export STEP files.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: STEP Export/Import colors override (?)

Post by realthunder »

easyw-fc wrote: Sat Oct 02, 2021 9:14 am I've added a note at the tracker:
https://tracker.freecadweb.org/view.php?id=4744#c15957

it could be related to OCC release version, not to FC version ...
PR submitted here. See the PR comments for more details. The PR also adds support for STEP transparency. It's a small change and somewhat related, so I just grouped them together.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP Export/Import colors override (?)

Post by easyw-fc »

realthunder wrote: Thu Oct 07, 2021 9:47 am PR submitted here. See the PR comments for more details. The PR also adds support for STEP transparency. It's a small change and somewhat related, so I just grouped them together.
@realthunder
Thanks a lot for taking care of it!

I've tested this branch under Linux and I noticed that Transparency attribute seems not to be exported correctly.
I have viewed the STP file in a text editor and I found:

Code: Select all

#181 = SURFACE_STYLE_TRANSPARENT(0.300000011921);
...
#194 = SURFACE_STYLE_TRANSPARENT(1.);
...
#204 = SURFACE_STYLE_TRANSPARENT(1.);
... 
... etc
Here the simple Cube with faced colored and transparency applied to shape file exported as STP
Transparent-Cube-stp.zip
(2.91 KiB) Downloaded 53 times
You can test the Import/export STP files with CadAssistant
https://www.opencascade.com/products/cad-assistant/
It is available for win, osx and Linux and it is handling transparency feature (no need to register to download and use)
latest version: cad_assistant_1.6.0_2021-10-05

May be we should split the commit in two ... one for fixing colors and one for transparency
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP Export/Import colors override (?)

Post by easyw-fc »

realthunder wrote: Thu Oct 07, 2021 9:47 am PR submitted here. See the PR comments for more details. The PR also adds support for STEP transparency. It's a small change and somewhat related, so I just grouped them together.
Hi @realthunder,
I have tested your recent update and it seems much better.
I just found a user case that may be needs an other tweak...
I'm attaching:
1) a cube with different coloured faces made transparent as shape
transparent-shape-cube.FCStd
(3.75 KiB) Downloaded 47 times
2) a cube with different coloured faces with two transparent faces and the shape solid
transparent-faces-cube.FCStd
(3.74 KiB) Downloaded 45 times
the exported stp files are reloaded fine in FC, but not in CadAssistant
3) the stp file with only the shape transparent, but with different colored faces is rendered as solid in CADA, but transparent in FC
transparent-shape-cube.stp
(9.44 KiB) Downloaded 78 times
4) the stp file with only the transparent coloured faces, and with the shape solid is rendered in the same way both in CADA and in FC, displaying the two faces as transparent
transparent-faces-cube.stp
(9.58 KiB) Downloaded 77 times
I don't know if the CADA approach is the one used in most CAD sw as SWork or PTC etc...

May be to keep the same appearance both in CADA and FC, when exorting a transparent cube with coloured faces, it would be possible to assign the same transparency both to shape and all faces ...
What do you think?
Is there some user having access to proprietary CAD to check in which way the two STP files are rendered?

EDIT

Here also
5) a cube with different coloured all transparent faces and with a transparent shape
transparent-shape-faces-cube.stp
(10.18 KiB) Downloaded 92 times
This is displayed similarly in FC and CADA.. I'm not sure if in CADA the transparency key is 'summed' between the face and the shape values


Thanks
Maurice
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP Export/Import colors override (?)

Post by easyw-fc »

and here the FC source file for
5) a cube with different coloured all transparent faces and with a transparent shape
transparent-shape-faces-cube.FCStd
(3.76 KiB) Downloaded 51 times
the exported stp file (the same of above)
transparent-shape-faces-cube.stp
(10.18 KiB) Downloaded 49 times
and the code I used to make the faces transparent

Code: Select all

App.ActiveDocument.Box.ViewObject.DiffuseColor=[(0.0, 0.0, 1.0, 0.5), (0.0, 1.0, 1.0, 0.5), (0.6666666865348816, 0.0, 0.0, 0.5), (1.0, 1.0, 0.0, 0.5), (0.0, 0.0, 1.0, 0.5), (0.0, 0.0, 1.0, 0.5)]
here the forum page related to 'per face transparency'
https://forum.freecadweb.org/viewtopic.php?t=16476
At the moment, the color editor of FreeCAD cannot set transparency, so the only way to set per-face transparency is from python.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: STEP Export/Import colors override (?)

Post by realthunder »

easyw-fc wrote: Sat Oct 09, 2021 9:54 pm Hi @realthunder,
I have tested your recent update and it seems much better.
I just found a user case that may be needs an other tweak...
I just tested these files with CADA and the PR branch, and didn't notice any problem. Have you sync the branch? Maybe can post the picture showing the problem?
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP Export/Import colors override (?)

Post by easyw-fc »

realthunder wrote: Sun Oct 10, 2021 7:05 am I just tested these files with CADA and the PR branch, and didn't notice any problem. Have you sync the branch? Maybe can post the picture showing the problem?
Hi @realthunder
here the issue I found:
1) the transparent-shape-cube.stp file is imported and rendered as transparent object in FC, but it is displayed as solid in CADA
(please note that there is a small issue in FC loading a transparent object ... the obj is loaded with its transparency value, but it is not displayed transparent until its transparent property is sligtly changed)
transparent-shape-cube.png
transparent-shape-cube.png (72.67 KiB) Viewed 2496 times
-
2) to have the same result I needed to set transparency also on all the faces of the cube
transparent-shape-faces-cube.png
transparent-shape-faces-cube.png (77.35 KiB) Viewed 2496 times
-
What I have noticed is that to get the same behavior in FC and CAD, displaying a shape with transparent property in FC, the exporter should apply transparency at least to all the faces or to shape and faces
-
transparency-shape-in-FC.png
transparency-shape-in-FC.png (61.76 KiB) Viewed 2461 times
Post Reply