[SOLVED] Show/Hide object in coin3d

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
apeltauer
Posts: 399
Joined: Fri Aug 11, 2017 2:19 pm

[SOLVED] Show/Hide object in coin3d

Post by apeltauer »

Hi all,

i would like to hide and show again a SoNode in coin3d.
To create a line with coin i use the root SoSeparator from the gui ViewProvider and add a new child. The child is my line with material and position.
This works fine and i can see the line.
Now i want to hide the line, and show it later again. Since today i always deleting the node when i wanted to hide it. And created new when showing it. But when the object is not just a line this is time consumption. So i want to hide the object and the later show it again. But i have not found a solution to disable/hide the node. Can anyone give me a hint where i need to search?

BR Manuel
Last edited by apeltauer on Tue Jun 16, 2020 2:38 pm, edited 1 time in total.
User avatar
Chris_G
Veteran
Posts: 2601
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Show/Hide object in coin3d

Post by Chris_G »

You can put your nodes under a Switch :

Code: Select all

my_switch = coin.SoSwitch()
# show children
my_switch.whichChild = coin.SO_SWITCH_ALL
# hide children
my_switch.whichChild = coin.SO_SWITCH_NONE
User avatar
apeltauer
Posts: 399
Joined: Fri Aug 11, 2017 2:19 pm

[Solved] Re: Show/Hide object in coin3d

Post by apeltauer »

Chris_G wrote: Tue Jun 16, 2020 9:59 am You can put your nodes under a Switch :

Code: Select all

my_switch = coin.SoSwitch()
# show children
my_switch.whichChild = coin.SO_SWITCH_ALL
# hide children
my_switch.whichChild = coin.SO_SWITCH_NONE
works like a charm....
thanks.....
Post Reply