Script to flip a groups child node visibility

BubbaRichardBubbaRichard Posts: 0
edited December 1969 in Daz Script Developer Discussion

I'm fairly new to Daz’s scripting but I did mess with it a few years ago (and I’ve been a programmer for 17 years.)

I’ve bought some models from meshbox and when I want to turn off the models visibility, it doesn’t. I have to mark each separate item in the hierarchy as either invisible or visible. Since many of meshbox’s models are complex that can take a little while. I was hoping to right a script (or download one) that I could run on each model I am flipping visible or invisible.
Any help?

Regards,
Bubba

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,867
    edited December 1969

    Although that is fairly simple to script, an even simpler option would be to select the root item and create a new group (Create>New Group...) with Parent Selected item(s) to the Group checked -then toggling the visibility of the group item will toggle all of the parented items, and if some of the items are already hidden they will remain hidden when you make the group visible (which would be trickier to script).

  • BubbaRichardBubbaRichard Posts: 0
    edited December 1969

    Thanks for the non answer

  • cwichuracwichura Posts: 1,042
    edited December 1969

    I asked about this a while back, and got enough hints to cobble together the below script. I use this all the time to flip visibility on a bone and all child bones (e.g., to hide the shin on down through the toes in a single click when a figure is wearing long boots).

    var startNode = Scene.getPrimarySelection();
    if ( startNode ) {
     var bNewVisibility;
    
     var nodes = [ startNode ];
     nodes = nodes.concat( startNode.getNodeChildren( true ) );
    
     if ( startNode.isVisible() ) {
      bNewVisibility = false;
     } else {
      bNewVisibility = true;
     }
    
     for ( var n = 0 ; n < nodes.length ; n++ ) {
      nodes[ n ].setVisible( bNewVisibility );
     }
    }
Sign In or Register to comment.