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

About the development of the FEM module/workbench.

Moderator: bernd

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

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

Post by UR_ »

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
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

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

Post by bernd »

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
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

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

Post by bernd »

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

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

Post by bernd »

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


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

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

Post by bernd »

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 33 times

Screenshot_20200318_083819.png
Screenshot_20200318_083819.png (179.91 KiB) Viewed 1689 times
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

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

Post by wmayer »

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
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

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

Post by bernd »

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

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

Post by bernd »

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
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

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

Post by bernd »

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
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

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

Post by wmayer »

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.
Post Reply