to select node in the needed figure

EdpaEdpa Posts: 46

I have  2 figures in a scene to example - Genesis(1) and Genesis (2).

I need to select Hip in Genesis (2).   

var roots = Scene.getNodeList();var itemLd=Scene.findNodeByLabel( "Genesis (2)" )itemLd.select(true );var itemLH=Scene.findNodeByLabel( "Hip" )itemLH.select(true );

But this code selects Hip in Genesis(1)

 

Post edited by Edpa on

Comments

  • hphoenixhphoenix Posts: 1,335

    Scene.findNodeByLabel(label_name) finds the FIRST node which matches the label_name.    If there are multiple ones, it only selects the first.  You'll need to find another way to narrow down your search.  Probably will need to find the figure's root node, then traverse downard to the hip, using Scene.getNodeList() and using a loop to iterate over it, matching the needed characteristics until you find it.

     

  • EdpaEdpa Posts: 46

    I try it, but I  have no result now

  • hphoenixhphoenix Posts: 1,335
    edited July 2018

    It's actually easier than that....I forgot about findNodeChildByLabel().  Try this:

    var itemLd=Scene.findNodeByLabel( "Genesis (2)" );var itemLh;if(itemLd){    itemLd.select(true );    itemLH=itemLd.findChildNodeByLabel( "Hip", true );  // recursion is set true, but for the hip it may be better/faster to be false	if(itemLH)	{            itemLH.select(true );		// Do anything else with itemLh as needed here	}}

    Remember, the first find ("Genesis (2)"), could return NULL, and it will only return the FIRST one found.  If you had multiple figures labelled "Genesis (2)" in your scene, it'll just return the first one it finds.  Which could change from load scene to scene.

     

    Post edited by hphoenix on
  • EdpaEdpa Posts: 46
    edited July 2018

    findChildNodeByLabel     I corrected the function name in script :)  - findNodeChildByLabel

    I tried to use getSelectedNodeList() with getNodeChildren together. As a result, I was able to sellect fully Genesis (2) :))

    Thank you very much! Your script works well

     

     

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