to select node with childrens in specific figure in scene

YudinEdYudinEd Posts: 90

I have some Genesis figures in the scene. I have select node with children in specific figure. I found the scripts here, similar to the solution of this problem.  But I select only the first figure in the list. But I have to work with the second, third and so on. What I can do?

I tried to do so. 

var Fig = Scene.findNodeByLabel( "Genesis (2)" ); // I try to work with 2th item in list Fig.select( true );if (Fig) {var item = Scene.findNodeByLabel( "Left Hand" );// "Left Hand" in Genesis(2)item.select( true );// Selected childrenvar roots = Scene.getSelectedNodeList();var n = roots.length;for( var i = 0; i < n; i++ ){selectChildren( roots[ i ] )}function selectChildren( root ){var children = root.getNodeChildren( true ); //recursevar n = children.length;for( var i = 0; i < n; i++ ){var node = children[ i ];node.select( true );}}}

 

Post edited by YudinEd on

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,888

    Use Scene.getSelectedSkeletonList() (if you want to deal with only selected items) or Scene.getSkeletonList() (if you don't care about selection state) then use skelList[ n ].getLabel().startsWith( "Genesis" ) to identify the Genesis figures (or whatever you want to look for).

  • YudinEdYudinEd Posts: 90

    I'll think risas.gif....

    I understand  Scene.getSkeletonList() and Scene.getSelectedSkeletonList() , but I see for the first time this function  skelList[ n ].getLabel().startsWith( "Genesis" ) . I imagine badly, where it is inserted and how to arrange it in the script no.gif

  • YudinEdYudinEd Posts: 90
    edited March 2017

    I tried now so. I haven't errors, but haven't results too. :) - no selected node with children (in my case "Left Hand" in Genesis(2) no.gif

    var item = Scene.findNodeByLabel( "Genesis (2)" );item.select( true );// Selected childrenvar skelList=Scene.getSelectedSkeletonList() var n = skelList.length;for( var i = 0; i < n; i++ ){if (skelList[i ].getLabel().startsWith( "Genesis(2)" ) ){	var children = skelList.getNodeChildren( true ); //recurseselectChildren(skelList[i] )}}function selectChildren(root ){var item = Scene.findNodeByLabel( "Left Hand" );// "Left Hand" in Genesis(2)item.select( true );var n = children.length;for( var i = 0; i < n; i++ ){var node = children[ i ];node.select( true );}}

     

    Post edited by YudinEd on
  • Richard HaseltineRichard Haseltine Posts: 100,888

    I was suggesting getting the list of skeletons, finding the oens that have a label starting with Genesis and then checking those for the second one, then using the findNodeChild on that to get and select the bones.

  • YudinEdYudinEd Posts: 90
    edited March 2017

    OK, now I select needed figure (Genesis 2) in scene with some chatacters and choose  the bone (lHandin this figure.

    I'll write later with children ( perhaps  risas.gif if I give birth)

    var roots = Scene.getSkeletonList()var n=roots.lengthfor ( var i = 0; i < n; i++ ){	if (roots[i].getLabel()=="Genesis (2)")	{				roots[i].select(false);		var LeftHand=roots[i].findBone( "lHand" );		LeftHand.select(true) 		    } 	}

     

    Post edited by YudinEd on
  • YudinEdYudinEd Posts: 90
    edited March 2017

    Next was easy :)

    var roots = Scene.getSkeletonList()var n=roots.lengthfor ( var i = 0; i < n; i++ ){	if (roots[i].getLabel()=="Genesis (2)")	{				roots[i].select(false);		var LeftHand=roots[i].findBone( "lHand" );		LeftHand.select(true) 		    } 	}// Selected childrenvar getSelNodeList = Scene.getSelectedNodeList();var n = getSelNodeList.length;for( var i = 0; i < n; i++ ){selectChildren( getSelNodeList[ i ] )}function selectChildren( root ){ var children = root.getNodeChildren( true ); var n = children.length;for( var i = 0; i < n; i++ ){var node = children[ i ];node.select( true );}}

     

    Post edited by YudinEd on
Sign In or Register to comment.