App::DocumentObjectGroupPython persistence

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

App::DocumentObjectGroupPython persistence

Post by damian »

OS: Ubuntu 14.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8749 (Git)
Build type: None
Branch: master
Hash: 3e82b3b10d6399a9b6fbff487e8e77a5cce0a628
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17


Good morning:

Yesterday I was coding an App::DocumentObjectGroupPython. I don't achieve the persistence of the Group between sessions.

For example, with a well known code

Code: Select all

>>> doc = App.newDocument("")
>>> import Arch
>>> wall=Arch.makeWall(length=1,name='my_wall')
>>> floor=Arch.makeFloor([wall])
>>> [o.Name for o in floor.Group]
['my_wall']
>>> doc.saveAs(u'/home/damian/my_doc')
In a new session:

Code: Select all

>>> doc=App.openDocument(u'/home/damian/my_doc')
>>> floor=doc.Floor
>>> floor.Group
[]
I don't know when this behaviour started.

Please, could anybody confirm (or not) this problem?

Thank
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: App::DocumentObjectGroupPython persistence

Post by ickby »

Hello,

Currently I can't test it, but as I have done some serious work on the code behind the group object lately I'm going to investigate that over the weekend.
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: App::DocumentObjectGroupPython persistence

Post by damian »

Thank @ickby
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: App::DocumentObjectGroupPython persistence

Post by yorik »

Indeed I see that problem too. Non-python groups also seem to have problems, after some drag-n-dropping of groups inside groups, things stop working. Example:
1) create three groups, one inside the other
2) try to move one of the subgroups out (to the document root)
3) try adding more groups and moving groups from one group to the other, everything begins to act weirdly... (Some messages like "cannot move group to itself", etc)
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: App::DocumentObjectGroupPython persistence

Post by damian »

Good morning

I'm checking the new Extensions. I can apply them to a Feature, but not to a Python Feature.

Code: Select all

>>> class My_Extension:
...     def __init__(self,obj):
...         obj.addExtension("App::GroupExtensionPython",self)
... 
>>> feature=doc.addObject("Part::Feature","my_feature")
>>> featurePython=doc.addObject("Part::FeaturePython","my_featurePython")
>>> My_Extension(feature)
<__main__.My_Extension instance at 0x7f660a2721b8>
>>> feature.PropertiesList
['ExpressionEngine', 'ExtensionProxy', 'Group', 'Label', 'Placement', 'Shape']
>>> My_Extension(featurePython)
<__main__.My_Extension instance at 0x7f660a2723b0>
>>> featurePython.PropertiesList
['ExpressionEngine', 'Label', 'Placement', 'Proxy', 'Shape']
>>> 
Thank

OS: Ubuntu 14.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8761 (Git)
Build type: Unknown
Branch: master
Hash: 96e9b7ee5b5728d859c1f0dc3e76d7fd4d137c7d
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.9.1
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: App::DocumentObjectGroupPython persistence

Post by ickby »

Hello,

the fix for persistency has been merged, that should work now. For the python feature extension issue I have to investigate again. As I currently hae not much time this may also take a while.
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: App::DocumentObjectGroupPython persistence

Post by wmayer »

@ickby if you talk about the example of featurePython.PropertiesList it now returns this list:
['ExpressionEngine', 'ExtensionProxy', 'Group', 'Label', 'Placement', 'Proxy', 'Shape']
i.e. it now includes the properties ExtensionProxy and Group
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: App::DocumentObjectGroupPython persistence

Post by ickby »

Ah unintentional double fix 8-) cool! Thanks for testing werner!
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: App::DocumentObjectGroupPython persistence

Post by damian »

Good afternoon:
yorik wrote:everything begins to act weirdly
What I can see is:

Code: Select all

>>> doc=App.newDocument()
>>> App.setActiveDocument("Unnamed")
>>> App.ActiveDocument=App.getDocument("Unnamed")
>>> Gui.ActiveDocument=Gui.getDocument("Unnamed")
>>> docGui=Gui.ActiveDocument
>>> doc.addObject('App::DocumentObjectGroup','firstGroup')
<group object>
>>> doc.addObject('App::DocumentObjectGroup','secondGroup')
<group object>
>>> docGui.ActiveView.setActiveObject('firstGroup',doc.firstGroup)
>>> doc.addObject('Part::Box','myBox')
<Part::PartFeature>
>>> doc.recompute()
>>> doc.firstGroup.addObject(doc.myBox)
>>> doc.secondGroup.Group
[<Part::PartFeature>]
>>> 
The last created group always acts "like the active group"?
The same behaviour happen with App::Part
Thank you

OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8905 (Git)
Build type: Unknown
Branch: master
Hash: 00829c7753582fcca46cabf68bd47f701032c2db
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: App::DocumentObjectGroupPython persistence

Post by wmayer »

Here the stripped code to reproduce the behaviour:

Code: Select all

doc=App.newDocument()
doc.addObject('App::DocumentObjectGroup','firstGroup')
doc.addObject('App::DocumentObjectGroup','secondGroup')
doc.addObject('Part::Box','myBox')
doc.recompute()
doc.firstGroup.addObject(doc.myBox)
doc.secondGroup.Group
Post Reply