Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1067

Problem about save pose parameters and set the parameter to another character

$
0
0

Hi,

I'm trying to use Daz script saving pose parameters (Position,rotation,scale), set the saved pose parameters to another character.

Here is the script I used to save all 233 labeled bone's parameter into 233 json files.

for example:

function save_pose(){

var aNodeList = Scene.getNodeList();

print(aNodeList.length);

for (i=1; i <aNodeList.length; i++){

var node = aNodeList[i];

var label= node.getLabel();

json_path = String("%1%2.json").arg("C:/Users/momo/Desktop/json/bone").arg(i);

var file = new DzFile(json_path);

file.open( DzFile.WriteOnly );

var oldNodeWSPos = node.getWSPos();

var oldNodeWSRot = node.getWSRot();

var oData = {};

var oSettings = new DzSettings();

if( oSettings.fromString( JSON.stringify( oData ) ) ){

oSettings.setFloatValue("Posx", oldNodeWSPos.x);

oSettings.setFloatValue("Posy", oldNodeWSPos.y);

oSettings.setFloatValue("Posz", oldNodeWSPos.z);

oSettings.setFloatValue("Rotx", oldNodeWSRot.x);

oSettings.setFloatValue("Roty", oldNodeWSRot.y);

oSettings.setFloatValue("Rotz", oldNodeWSRot.z);

};

var sTemplateData = oSettings.toJsonString();

var nResult = file.write( sTemplateData );

print(sTemplateData);

node.select( false );

file.close();

}}

 

Then get the parameters from json , set the parameters to another character.

The script should works well, but look at the result actually didn't set well.

code:

function set_pose(){

var aNodeList = Scene.getNodeList()

print(aNodeList.length)

for (i=1; i <aNodeList.length; i++){

var oNode = aNodeList[i];

var label= oNode.getLabel();

print(label);

json_path = String("%1%2.json").arg("C:/Users/momo/Desktop/json/bone").arg(i);

var oFile = new DzFile(json_path);

if (oFile.open (DzFile.ReadOnly)) {

var oData;

oData = JSON.parse (oFile.read());

Scene.getPrimarySelection().findNodeChildByLabel(label, true).getXRotControl().setValue(oData["Rotx"]);

Scene.getPrimarySelection().findNodeChildByLabel(label, true).getYRotControl().setValue(oData["Roty"]);

Scene.getPrimarySelection().findNodeChildByLabel(label, true).getZRotControl().setValue(oData["Rotz"]);

}} }

 

when I just change one bone, for example:

Scene.getPrimarySelection().findNodeChildByLabel("Left Collar", true).getXRotControl().setValue(50);

this could works well!

Can anyone help? Thanks!


Viewing all articles
Browse latest Browse all 1067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>