obj.Proxy.Type is a dict, not a string

About the development of the FEM module/workbench.

Moderator: bernd

UR_
Posts: 1188
Joined: Tue Jan 03, 2017 8:42 pm

obj.Proxy.Type is a dict, not a string

Postby UR_ » Mon Mar 09, 2020 8:20 am

ViewProviderFemConstraint.py line 51 should be:

Code: Select all

        file_name = self.Object.Proxy.Type.get("Type").replace("Fem::", "FEM_")

Shouldn't it? ;)

bernd wrote: :bell:

please compare git commit 5829fc4
User avatar
bernd
Posts: 10119
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: obj.Proxy.Type is a dict, not a string

Postby bernd » Mon Mar 09, 2020 2:11 pm

no not IMHO. I need to have a closer look ...

The time beeing the icons in tree view are deactivated for the python objects ... git commit 8b84a1cc94
User avatar
bernd
Posts: 10119
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: obj.Proxy.Type is a dict, not a string

Postby bernd » Tue Mar 10, 2020 7:56 pm

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

Re: obj.Proxy.Type is a dict, not a string

Postby bernd » Tue Mar 10, 2020 9:03 pm

git commit f41a942b0e works for me for most of the icons ...


all_objects.FCStd
(25.52 KiB) Downloaded 5 times
User avatar
bernd
Posts: 10119
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: obj.Proxy.Type is a dict, not a string

Postby bernd » Wed Mar 18, 2020 7:39 am

I have a file which shows the problem. Seams we need werner here ...

Two mesh regions, one does have an icon one not :shock:

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.20121 (Git)
Build type: Unknown
Branch: master
Hash: 2a50a19564a773b1977ee4158e6538dd0ca9315f
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)

Here is the relevant code https://github.com/FreeCAD/FreeCAD/blob ... py#L51-L66

error on file loading.

Code: Select all

No icon returned for MeshRegion
{'Type': {'Type': 'Fem::FemMeshRegion'}}

icon_problem.FCStd
(69 KiB) Downloaded 7 times

Screenshot_20200318_083819.png
Screenshot_20200318_083819.png (179.91 KiB) Viewed 249 times
wmayer
Site Admin
Posts: 15946
Joined: Thu Feb 19, 2009 10:32 am

Re: obj.Proxy.Type is a dict, not a string

Postby wmayer » Wed Mar 18, 2020 10:43 am

Code: Select all

self=App.ActiveDocument.MeshRegion.ViewObject.Proxy
self.Object.Proxy.Type # {'Type': {'Type': 'Fem::FemMeshRegion'}}

self001=App.ActiveDocument.MeshRegion001.ViewObject.Proxy
self001.Object.Proxy.Type # 'Fem::MeshRegion'
I don't know why "{'Type': {'Type': 'Fem::FemMeshRegion'}}" is assigned to the Type attribute of the proxy class.

You can assign a new value to Type

Code: Select all

self001.Object.Proxy.Type = 'Fem::MeshRegion'
and hide and show the object to fix its icon.

After changing the value of Type, saving the project and reloading it the old bad value is back. So, somewhere in the code something is wrong.
User avatar
bernd
Posts: 10119
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: obj.Proxy.Type is a dict, not a string

Postby bernd » Wed Mar 18, 2020 11:00 am

me neither, this is the problem I am facing with. OK, Fixing the object is not that difficault by Python. :)
User avatar
bernd
Posts: 10119
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: obj.Proxy.Type is a dict, not a string

Postby bernd » Wed Mar 18, 2020 11:11 am

I thought this happens at file load and thus it should be a problem in my FEM code somehow.

AFAIK the type property of the proxy is not saved in the FreeCAD file?! At least I could not found anything in Document.xml or GuiDocument.xml.

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

Re: obj.Proxy.Type is a dict, not a string

Postby bernd » Wed Mar 18, 2020 11:21 am

wmayer wrote:
Wed Mar 18, 2020 10:43 am
After changing the value of Type, saving the project and reloading it the old bad value is back. So, somewhere in the code something is wrong.
ahh I missed this, just tested and I get even more interfaced type dictionaries on saving and reloading ...
wmayer
Site Admin
Posts: 15946
Joined: Thu Feb 19, 2009 10:32 am

Re: obj.Proxy.Type is a dict, not a string

Postby wmayer » Wed Mar 18, 2020 11:22 am

The culprit is https://github.com/FreeCAD/FreeCAD/blob ... int.py#L42

If you change it to:

Code: Select all

    def __setstate__(self, state):
        #if state:
        #    self.Type = state
        print (self, " ", state)
the broken icons are fixed. The printed content is:
<femobjects._FemMeshRegion._FemMeshRegion object at 0x7fe9f97441d0> {'Type': {'Type': 'Fem::FemMeshRegion'}}
<femobjects._FemMeshGmsh._FemMeshGmsh object at 0x7fe9f9610f60> {'Type': 'Fem::FemMeshGmsh'}
<femobjects._FemMeshGmsh._FemMeshGmsh object at 0x7fe9e40420b8> {}
<femobjects._FemMeshRegion._FemMeshRegion object at 0x7fe9e4042240> {}
So, in some of your __getstate__ methods you return an inappropriate dict.