Load a poser preset by script

BubbsiBubbsi Posts: 6

Hello Guys,

I´ve once more a question =).

So I want to load a poser preset for a genesis2 model. My Problem is if the correct node isn´t selected in the scene I can´t load the poser, so the preset will only load for an other object :/.

I researched the Scene class documentation but I can´t find the right function to select an individual node.

Can anyone help me, plz?


David.

Post edited by Bubbsi on

Comments

  • Richard HaseltineRichard Haseltine Posts: 101,507
    edited December 1969

    Remember that some Poser files at least will not work on Genesis 2 - they require conversion to .duf files first. Or do you mean a native pose preset, not a Poser file?

    If you know the label of your target item you can use Scene.findNodeByLabel( label ) and then node.select( true ) to make it selected (you may also want to make sure nothing else is selected)

    var item = Scene.findNodeByLabel( "cube" );
    if ( item ) {
     item.select( true );
    }

    you can also use Scene.findNode( name ) to search by name.

  • BubbsiBubbsi Posts: 6
    edited December 1969

    It´s my own poser preset so it works =).

    you know the label of your target item you can use Scene.findNodeByLabel( label ) and then node.select( true ) to make it selected (you may also want to make sure nothing else is selected)

    This was what I searched for, thank you!

    But now there are two Items selected. I tried to Clear my selection with action = getAction(166) (166 number for "Clear Selection") and action.trigger(). the script works, but nothing happens :P.

  • rbtwhizrbtwhiz Posts: 2,267
    edited November 2015

    The index of an action can/will change as new functionality is added, be it in the core or through a plugin, so you don't want to use an index to find an action. The recommended approach is to use the classname of the action like I do in this sample.

    You can find the classname of an action using this sample.

    You can also directly deselect all nodes, and then select the desired node, like so...

    // Declare working variablesvar sSkeletonLabel = "Genesis 2 Female";var sBoneName = "abdomen2";var oNode = null;// Get all of the selected nodesvar aNodes = Scene.getSelectedNodeList();// Iterate over the nodesfor( var i = 0; i < aNodes.length; i += 1 ){ // Get the 'current' node oNode = aNodes[ i ]; // Deselect it oNode.select( false );}// Find the desired skeletonoNode = Scene.findNodeByLabel( sSkeletonLabel );// If the node was found and its a skeletonif( oNode && oNode.inherits( "DzSkeleton" ) ){ // Find the desired bone of the skeleton oNode = oNode.findNodeChild( sBoneName, true ); // If the node was found and its a bone if( oNode && oNode.inherits( "DzBone" ) ){  // Select it  oNode.select( true ); }}

     

    -Rob

    Post edited by Richard Haseltine on
Sign In or Register to comment.