newbie question : how to set the position and rotation of a character ?

hello,

I'm just trying to use daz script to set the position and rotation of my character to 0 for x,y,z after posing it

I've looked at the doc and the script about move to the floor but it's linked to a page not found (http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/core/move_to_floor/start)

Any help welcome

thanks

 

Comments

  • How far are you getting?

    var item = Scene.getPrimarySelection();

    will get you the primary selection - you can also get a selected node list which has everything.

    if ( item.inherits( "DzBone" ) {

    item = item.getSkeleton();

    }

    will get the figure if a bone is selected.

    Once you have a node, presumably the figure, you can use item.findNodeChild( "name" , true ) to look for children (bones, in this case - true tells it to look through children, grandchildren etc). Presuambly you'd want the figure and the hip since those are the nodes with translations.

    To adjust the position of the node you need item.getXPosControl(), item.getXRotControl() and their Y and Z equivalents, then for each you would use control.setValue( 0 ) to zero them.

  • thanks a lot Richard for your quick reply, it helped a lot and now I'm starting to understand better how it works

    so here's my first Daz script, the purpose is to select the figure and the hip and set these values to 0, using a function

    if it can help some newbies ;)

    //select the figure
    var item = Scene.getPrimarySelection();
    if ( item.inherits( "DzBone" )) {
    	item = item.getSkeleton();
     }
    
    if ( item ) {
     Set_PosRot_to_Zero (item)
     }
    
    //select the Hip node of the figure
    var item = Scene.findNodeByLabel( "Hip" );
    
    if ( item ) {
     Set_PosRot_to_Zero (item)
     }
    
    function Set_PosRot_to_Zero (item){
    
     item.select( true );
     print (item.name)
     print ("tx: " + item.getXPosControl().getValue())
     print ("ty: " + item.getYPosControl().getValue())
     print ("tz: " + item.getZPosControl().getValue())
     print ("rx: " + item.getXRotControl().getValue())
     print ("ry: " + item.getYRotControl().getValue())
     print ("rz: " + item.getZRotControl().getValue())
     item.getXPosControl().setValue(0)
     item.getYPosControl().setValue(0)
     item.getZPosControl().setValue(0)
     item.getXRotControl().setValue(0)
     item.getYRotControl().setValue(0)
     item.getZRotControl().setValue(0)
    }

     

  • Glad to help. I might have checked that each of the controls existed before doing anything with them, but I think that's a fairly safe assumption.

Sign In or Register to comment.