.hidden property and groups (scripting)

 From:  Michael Gibson
11120.2 In reply to 11120.1 
Hi Peer, just to make sure I understand, you're talking about setting the .hidden property from inside some of your own script code, not about setting it using the regular MoI UI, right?


> It seems like setting hidden on a parent object recursively sets hidden to the same value on all of
> that parent's children,

Yes.


> but that the same sort of thing doesn't happen when setting a child.

Yes, that's correct, if it did try to do the same thing it could have some potentially strange effects. Like if you set .hidden = false on a child object, it would probably be weird for hidden = false to be set on parent groups which would cause objects in other sibling sub trees of the group to get hidden.


> What's a nice way to show a child object when some of its parents are hidden? In
> particular, if I'm hiding some objects and also showing others, how do I make sure
> that what I want to show stays non-hidden that that what I want to hide stays
> hidden without any interaction between these operations?

You'll probably need to do the showing first. If the object you want to have shown is inside of a group then set hidden = false on the top level group:

obj.hidden = false;
var toplevel = obj.getTopLevelParent();
if ( toplevel.isGroup )
   toplevel.hidden = false;

Do that on all objects you want shown.

Then set .hidden = true on stuff that you want hidden.

- Michael

EDIT: Fixed typo - set .hidden = true on stuff you want hidden.

EDITED: 7 Jun 2023 by MICHAEL GIBSON