Nested group visibility

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Nested group visibility

Post by sliptonic »

I have a top-level PythonFeature object with the Group extension applied. It has child groups that are regular DocumentObjectGroups. But the child group visibility doesn't behave like I expect. I can toggle visibility at the parent level and it works but at the intermediate group level, it only turns visibility off, not back on. Is there something else I need to do to make the intermediate group behave normally?

Here's a macro that sets up the situation.

Code: Select all

class MyObject():
    def __init__(self,obj):
        obj.Proxy = self
        obj.addExtension("App::GroupExtensionPython")

class ViewProvider_MyObject():
    def __init__(self,vobj):
        #vobj.Proxy = self
        vobj.addExtension("Gui::ViewProviderGroupExtensionPython")

obj=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","parent")
MyObject(obj)
obj.ViewObject.Proxy = ViewProvider_MyObject(obj.ViewObject)
child = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup", "child")
obj.addObject(child)
box = App.ActiveDocument.addObject("Part::Box","Box")
child.addObject(box)
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Nested group visibility

Post by carlopav »

Indeed it behaves strange...
What's the desired result of this setting? What do you want to achieve?
Why using a Part::FeaturePython instead of an App::FeaturePython?
follow my experiments on BIM modelling for architecture design
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Nested group visibility

Post by sliptonic »

Sorry. The part::featurepython was already in my script. I get the same behaviour in app::featurepython.

I want the groups to behave the same as nested documentobjectgroups. Toggling the parent should toggle all children off and on.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Nested group visibility

Post by carlopav »

hmmm, yes, I get your same behaviour with Part::Feature Python, while it's working with App::FeaturePython:

Code: Select all

class MyObject():
    def __init__(self,obj):
        obj.Proxy = self
        obj.addExtension("App::GroupExtensionPython")

class ViewProvider_MyObject():
    def __init__(self,vobj):
        #vobj.Proxy = self
        vobj.addExtension("Gui::ViewProviderGroupExtensionPython")

    def __getstate__(self):
        return None

    def __setstate__(self, _state):
        return None

obj=FreeCAD.ActiveDocument.addObject("App::FeaturePython","parent")
MyObject(obj)
obj.ViewObject.Proxy = ViewProvider_MyObject(obj.ViewObject)
child = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup", "child")
obj.addObject(child)
box = App.ActiveDocument.addObject("Part::Box","Box")
child.addObject(box)
I guess It still misses some methods cause the viewprovider has a bad icon in the tree...
can you try?
follow my experiments on BIM modelling for architecture design
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Nested group visibility

Post by sliptonic »

It doesn't work with App::featurepython for me either.

If the child group is not visible, toggling the parent makes it visible but not the reverse.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Nested group visibility

Post by carlopav »

this is quite odd... i confirm that App::FeaturePython works with the following setup:

Code: Select all

OS: Windows 10 Version 2004
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Italian/Italy (it_IT)
I'm interested in the topic, hope you can find a solution...
follow my experiments on BIM modelling for architecture design
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Nested group visibility

Post by sliptonic »

I'm on the current master branch.

OS: Linux Mint 20 (i3/i3)
Word size of FreeCAD: 64-bit
Version: 0.20.25220 (Git)
Build type: Unknown
Branch: master
Hash: 46282db7c8c65d1205a4cd03499d4beadb1573c6
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.3.0
Locale: English/United States (en_US)
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Nested group visibility

Post by carlopav »

No time now to compile, sorry. I tried with 0.19.2

Code: Select all

OS: Windows 10 Version 2004
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Italian/Italy (it_IT)
Attachments
toggle visibility.gif
toggle visibility.gif (41.72 KiB) Viewed 1344 times
follow my experiments on BIM modelling for architecture design
User avatar
Roy_043
Veteran
Posts: 8585
Joined: Thu Dec 27, 2018 12:28 pm

Re: Nested group visibility

Post by Roy_043 »

It does work partially. And this is maybe what Carlo is seeing?
  • Use the code from the OP.
  • Make all objects invisible.
  • Toggling the visibility of the intermediate group now works.
Post Reply