Digital Art Zone

 
     
Script to toggle visibility of a node and all children nodes?
Posted: 08 May 2013 02:05 PM   [ Ignore ]
Power Member
RankRankRank
Total Posts:  1003
Joined  2012-02-04

Anyone aware of a script for Studio that will toggle the visibility of a selected node and all of its children nodes in one shot?  This would be useful for things like turning off the left or right collar on down through all the fingers on a set of gloves when you only want the left or right glove, for example.  Obviously, one can toggle each node manually, but when there are a lot of nodes, it’s a nuisance due to the UI lag when toggling nodes.

Thanks

 Signature 

My deviantART Homepage

Profile
 
 
Posted: 08 May 2013 03:17 PM   [ Ignore ]   [ # 1 ]
Addict
Avatar
RankRankRankRank
Total Posts:  4922
Joined  2008-03-06

You don’t have to toggle them individually.  Select the root note you want to start from in the Scene Tab and right-click, then choose Select Children.  Now you can toggle them all invisible simultaneously in Parameters tab—Display.  Just make sure you turn off both Visible and Visible In Render.

 Signature 

My store at DAZ.

My Deviantart gallery.

Profile
 
 
Posted: 08 May 2013 03:17 PM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14008
Joined  2003-10-09

You can multi-seelct and then turn the visibility off for all in the Parameters pane, but something like

var startNode Scene.getPrimarySelection();
if ( 
startNode {
 
var nodes [ startNode ];
 
nodes nodes.concatstartNode.getNodeChildrentrue ) );
 for ( var 
nodes.length n++ ) {
  nodes[ n ]
.setVisiblefalse );
 
}

and the same with nodes[ n ].setVisible( true ); to show them again.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 08 May 2013 03:18 PM   [ Ignore ]   [ # 3 ]
Addict
Avatar
RankRankRankRank
Total Posts:  4922
Joined  2008-03-06

Crosspost with Mr. Kitty Cat. wink  Or you can do that.

 Signature 

My store at DAZ.

My Deviantart gallery.

Profile
 
 
Posted: 08 May 2013 06:23 PM   [ Ignore ]   [ # 4 ]
Power Member
RankRankRank
Total Posts:  1003
Joined  2012-02-04

Hmm, so the elements in the Display sub-category correspond to the node visibility icon in the Scene list?  I’ve never actually messed with the stuff under Display.  But the visibility icons in the Scene list ignore multi-selection, hence my original request.  If you toggle them in the Display sub-category, does the visibility icon also change?

And thanks Richard for the script.  I’ll give that a try when I’m back in the office tomorrow.

 Signature 

My deviantART Homepage

Profile
 
 
Posted: 09 May 2013 05:18 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14008
Joined  2003-10-09

Yes, the eye in the Scene pane and the visibility button in Parameters are the same property, just different ways to access it - that’s also true of the selectable control

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 09 May 2013 10:44 AM   [ Ignore ]   [ # 6 ]
Power Member
Avatar
RankRankRank
Total Posts:  1453
Joined  2003-10-09

Very handy info.  Thanks!

Profile
 
 
Posted: 12 May 2013 03:12 AM   [ Ignore ]   [ # 7 ]
Power Member
Avatar
RankRankRank
Total Posts:  1881
Joined  2012-03-24

Richarrrrrd ^^;
one more quesiton,,, I simply make visible selection node and children , sciot

(just change “false” to “true” ) from your auto invisible selection node and children scirpt.

but as you know,, when I hope to visble under r-foot,, if the root genesis set invisibe,
it can not work,,

so I may need apply code,,

“if root node is invsible turn root visible “
“else you need not do anything,, it may work”

so please tell me the ds script code to do it^^;

============
or simply I need to apply ,
anyway select root ,set root visible.

I know it is so easy,, but where is good place to understand each ID or action etc in daz studio?  ^^;
or would not you tell me the link of them directly?

Profile
 
 
Posted: 12 May 2013 05:52 AM   [ Ignore ]   [ # 8 ]
Power Member
Avatar
RankRankRank
Total Posts:  1881
Joined  2012-03-24
var startNode Scene.getPrimarySelection();


if ( 
startNode {
  
var nodes [ startNode ];
 
nodes nodes.concatstartNode.getNodeChildrentrue ) );
 for ( var 
nodes.length n++ ) {
  nodes[ n ]
.setVisibletrue );
 
};
 
 var 
rootNodeTemp startNode;
 var 
checkRoot rootNodeTemp.isRootNode(); 
 while(
checkRoot == false){;
   
rootNodeTemp rootNodeTemp.getNodeParent();
   
checkRoot rootNodeTemp.isRootNode();
  
}
 rootNodeTemp
.setVisibletrue ); 
 
}

is it wrong?

Profile
 
 
Posted: 12 May 2013 08:09 AM   [ Ignore ]   [ # 9 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14008
Joined  2003-10-09

You could also try adding this to the loop

for ( var nodes.length n++ ) {
  nodes[ n ]
.setVisibletrue );
  if ( 
nodes[ n ].inherits"DzBone" {
   
if ( nodes[ n ].getSkeleton() ) {
    nodes[ n ]
.getSkeleton().setVisibletrue );
   
}
  }
 } 

Or it may be more efficient to use Scene.getSelectedSkeletonList() at the start and make all of those visible before going through the nodes, though with a simple script like this the overhead of checking the same skeleton repeatedly if multiple bones are selected probably doesn’t matter.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 12 May 2013 08:35 AM   [ Ignore ]   [ # 10 ]
Power Member
Avatar
RankRankRank
Total Posts:  1881
Joined  2012-03-24

I checked skelton and bone method and property etc,, but it was difficult to understand at first challenge how to use them,,, ^^;

Is not there “method”  which serch and direct get the root node and return it,, by current selected Node?
like,, getRootNodeEasy() ,, I hoped and serched it,,,^^; 

“if multiple bones are selected” yes,, I know,,I thought the case,, if apply multselection, it can be more useful.
But,,, actually,,,,I do not like scripting so ,,,  ^^;
anyway thank you much.

Profile
 
 
Posted: 12 May 2013 12:31 PM   [ Ignore ]   [ # 11 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14008
Joined  2003-10-09

The skeleton is the root node of the figure - strictly speaking, the root node inherits DzSkeleton but is a derivative object in DS4, figures are now either Poser figures or TriAx figures, but in DS3 all figures (except Optitex cloth perhaps) were plain DzSkeletons.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 12 May 2013 12:34 PM   [ Ignore ]   [ # 12 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14008
Joined  2003-10-09

The other way to get at the root, if you also want to get the top of a set or parented props or a group, is to use something like

var root node;
while ( 
root.getNodeParent() } {
     root 
root.getNodeParent();

which is slightly simpler than your script. You can then build an array of roots by declaring an array and using array.pushIfNotExists( root ) to make sure each root is added only once, then go through that array doing whatever it is you want (rather than getting the root for each node and performing the action on that, possibly adding unneeded repeats).

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 12 May 2013 01:20 PM   [ Ignore ]   [ # 13 ]
Power Member
Avatar
RankRankRank
Total Posts:  1881
Joined  2012-03-24

thank you,,,, I keep tweaking,, array etc,,I may keep studying, step by step,,

Now I check your script one by one,, about method and dzclass,,etc,,
I now understand how to get selected multi node as array,,
and get the qobject name,,,

.(I do not like scripting,, but feel interesting now ^^;)

and I may hope more quesiton,,, so where is best forum to ask these?
nuts and bolts may ok? or new user forum?

because my quesiton seems so basic,, i think,, eg,,
I want to know,, save as documents which I indicate in message box.
I saw script rdwigh wrote,,, which show all short cut,, but I hope to save it as txt.

so I am serching way,, which class or method may work,,to save it as txt.
anyway,, good night,sir Richard I need to sleep now ^^;

Profile
 
 
Posted: 12 May 2013 03:49 PM   [ Ignore ]   [ # 14 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14008
Joined  2003-10-09

This is the forum intended for scripting http://www.daz3d.com/forums/viewforum/60/http://www.daz3d.com/forums/viewforum/60/

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile