Page 1 of 2

Can't save color

Posted: Fri Nov 20, 2020 7:25 am
by johnwang
Hi,

Using this code to generate a FemMesh object with two triangle elements. Then changed the color of one element. But after saving and reopen, the color is lost.

Regards,

John

Code: Select all

import Fem

a = Fem.FemMesh()

a.addNode(0,    0,    0,    1)
a.addNode(10,    0,    0,    2)
a.addNode(5,    10,    0,    3)
a.addNode(15,    15,    0,    4)

a.addFace([1,2,3], 1)
a.addFace([2,4,3], 2)
obj = FreeCAD.ActiveDocument.addObject("Fem::FemMeshObject")
#obj.Placement.Base = FreeCAD.Vector(2, 0, 0)
obj.FemMesh = a

obj.ViewObject.ElementColor = {1:(1,0,0)}
tc.jpg
tc.jpg (23.16 KiB) Viewed 361 times
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20839 (Git)
Build type: Release
Branch: master
Hash: 09005766f10539dfe32314c33c2cd3efe9141d0b
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)

Re: Can't save color

Posted: Fri Nov 20, 2020 8:20 am
by kisolre
Please retry with latest build. There are some 2200 commits since your version. Might be fixed already...

Re: Can't save color

Posted: Fri Nov 20, 2020 9:38 am
by johnwang
kisolre wrote:
Fri Nov 20, 2020 8:20 am
Please retry with latest build. There are some 2200 commits since your version. Might be fixed already...
Not working in 22900 either.

Re: Can't save color

Posted: Tue Nov 24, 2020 7:13 am
by bernd
moved to FEM to not miss it

Re: Can't save color

Posted: Tue Nov 24, 2020 7:15 am
by bernd
How did you changed the color? By python too? Would you provide this code as well?

bernd

Re: Can't save color

Posted: Tue Nov 24, 2020 7:32 am
by johnwang
the last sentence.

Re: Can't save color

Posted: Tue Nov 24, 2020 8:48 am
by bernd
johnwang wrote:
Tue Nov 24, 2020 7:32 am
the last sentence.
ahh I missed this. BTW if you add a new line at the end of code blocks the last line is executed without pressing another time enter after copy past.

confirmed for

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22960 (Git)
Build type: Release
Branch: master
Hash: c5a4b01d2e4218bcc0eb6650337650a6c65ef0e4
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Switzerland (de_CH)


ATM I have no idea why. You said you filled a bug report. would you post the link. I allready deleted the pm :oops:

Re: Can't save color

Posted: Tue Nov 24, 2020 9:04 am
by johnwang

Re: Can't save color

Posted: Tue Nov 24, 2020 9:15 am
by bernd
AFAIK this method is used to set the colors:

https://github.com/FreeCAD/FreeCAD/blob ... h.cpp#L651

this only sets the scene graph, but the colors are not saved anywhere AFAIKT

Re: Can't save color

Posted: Tue Nov 24, 2020 9:15 am
by bernd
johnwang wrote:
Tue Nov 24, 2020 9:04 am
a bug report at:
https://tracker.freecadweb.org/view.php?id=4499
better to use the but icon in the forum ... issue #4499