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 figurevar item = Scene.getPrimarySelection();if ( item.inherits( "DzBone" )) {	item = item.getSkeleton(); }if ( item ) { Set_PosRot_to_Zero (item) }//select the Hip node of the figurevar 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.

  • functionfunction Posts: 283
    edited April 2023

    Richard Haseltine said:

    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.

    Hello Richard, Value(0) is not always the floor. For example, a female wear a high heel shoes, after ctrl+D, her Y translate is above 0, use this script will move her feet under the floor.

    Maybe this is the reason they deleted the 'move to floor' script example. Now how to make a ctrl+D function in a script? 

    Post edited by function on
  • Richard HaseltineRichard Haseltine Posts: 100,905
    edited April 2023

    In that case you would need to calculate the offset.

    Although Drop to Floor was originally a script it has since been promoted to an actual compiled feature, as far as I know - I would imagine that is why the script is no longer listed. Still is a scipt, I am told, sorry. As for the link, that may well be set live at a later date.

    Post edited by Richard Haseltine on
  • functionfunction Posts: 283
    edited April 2023

    Richard Haseltine said:

    In that case you would need to calculate the offset.

    Although Drop to Floor was originally a script it has since been promoted to an actual compiled feature, as far as I know - I would imagine that is why the script is no longer listed. Still is a scipt, I am told, sorry. As for the link, that may well be set live at a later date.

    Ok, thanks. 

    Now I found some script from otherwhere and edited for this script, put below scentences in this post 3rd floor's script before the "//select the Hip node of the figure" and malfunction all sentences after the Print:

     

    topy = item.getWSBoundingBox().minY;  

    dy = 0 - topy;  

    topPos = item.getWSPos();  

    topPos.y += dy;  

    item.setWSPos( topPos );  

    It works but, not exactly. It just move the figure's lowest point which is almost the toes to the floor, not calculate the shoes size, so that the shoes' sole still underground...

    ---------

    edited: the problem solved, put Ctrl+D Action into the script, see my other post here:

    https://www.daz3d.com/forums/discussion/628891/anyway-to-add-a-keyboard-shortcut-to-a-script

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