recovering viewprovider after working in no-gui-mode

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

recovering viewprovider after working in no-gui-mode

Post by looo »

Ssomehow the python proxy of the viewprovider gets lost after working in no-gui-mode (jupyter-notebook). While it makes sense that no view-provider is stored in no-gui-mode, my object won't work without the proxy of the viewprovider.

the 2 attachments show the problem.

1. create line in draft and save as fc_with_gui.fcstd
2. start fc in no-gui mode:

Code: Select all

import FreeCAD
doc = FreeCAD.openDocument("fc_with_gui.fcstd")
doc.save("fc_without_gui.fcstd")
3. open the file in freecad (with gui)
Attachments
fc_without_gui.fcstd
(2.11 KiB) Downloaded 16 times
fc_with_gui.fcstd
(3.76 KiB) Downloaded 19 times
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: recovering viewprovider after working in no-gui-mode

Post by microelly2 »

Does it make sense to recreate the viewprovider after "the document is restored"?

onDocumentRestored(self, obj):
ViewProvider(obj.ViewObject)
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: recovering viewprovider after working in no-gui-mode

Post by looo »

microelly2 wrote:Does it make sense to recreate the viewprovider after "the document is restored"?

onDocumentRestored(self, obj):
ViewProvider(obj.ViewObject)
I am not sure if it is the right way. I guess this fnction is also called in nogui-mode.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: recovering viewprovider after working in no-gui-mode

Post by microelly2 »

looo wrote: Wed May 02, 2018 4:07 pm [I am not sure if it is the right way. I guess this fnction is also called in nogui-mode.
but you can check whether the gui is up at that moment
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: recovering viewprovider after working in no-gui-mode

Post by looo »

yes thats a good idea.
Post Reply