DAZ script for erc-bake multipel files

Hello,

I have a bunch of file where I want to remove the erc-freeze.

I figured out that erc-bake is the way to go, but erc-bake is only working for one file at once.

so, I thought maybe a little script could be wirtten do this.

I was thinking about a script that removes from all favourite morphs the erc-freeze.

erc-bake is availibe via the script api.

http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/ercbake_dz#a_1a0fa552d18aa130c9ad8ac83f17d1f89d

unfortunatelly I have no clue about DAZ scripting.
any hint how I collect all favourite morphs and pass them in a loop to erc-bake?

Comments

  • Hurdy3DHurdy3D Posts: 1,047
    edited October 2022

    I made asmall progress:

     


    var nodeDzNode = Scene.getPrimarySelection();

    var nodeDzObj = nodeDzNode.getObject()

    var modifier = nodeDzObj.getPropertyGroups().findPropertyByLabel( 'Morph name');

    debug(modifier)

    debug(new DzERCBake().getControllerProperty(modifier));

     


    The main issue is, that getControllerProperty doesn't accept my Property, return is always null:

     

    Executing Script...

    [object Object]
    null
    Result: 
    Script executed in 0 secs 1 msecs.

     

    Any idea what I have to do here?
    The docu is not pretty helpful here http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/ercbake_dz#a_1a0fa552d18aa130c9ad8ac83f17d1f89d

    Post edited by Hurdy3D on
  • I'd add soem error-checking to the script, especially I would break down var modifier = nodeDzObj.getPropertyGroups().findPropertyByLabel( 'Morph name'); into separate steps and check that each strep of the process was giving a valid return.

  • Hurdy3DHurdy3D Posts: 1,047

    Richard Haseltine said:

    I'd add soem error-checking to the script, especially I would break down var modifier = nodeDzObj.getPropertyGroups().findPropertyByLabel( 'Morph name'); into separate steps and check that each strep of the process was giving a valid return.

    Yes, I already checked that one.
    findPropertyByLabel() returns the morph, I tested even reading the current value of the morph.

    However, the thing I don't get is:
    findPropertyByLabel() returns a value from from the type  DzProperty
    getControllerProperty()  expects a DzNumericProperty.

    How can I utlize the result of findPropertyByLabel() for getControllerProperty()  ?

  • Hurdy3DHurdy3D Posts: 1,047
    edited October 2022

    ok I found a solution:

     

    var nodeDzNode = Scene.getPrimarySelection();

    var nodeDzObj = nodeDzNode.getObject()

    var modifier = nodeDzObj.getPropertyGroups().findPropertyByLabel( 'Morph Name');

    debug(modifier)

    var bake = new DzERCBake();

    bake.setControllerProperty(modifier);

    bake.doBake();

    I used DzERCBake in a wrong way.

    So... no I have to figure out how to get a list all favourite morphs, any idea?

     

    Post edited by Hurdy3D on
  • Hurdy3DHurdy3D Posts: 1,047
    edited October 2022

    Someone has to say it: I'm a so [super-duper] S-M-R-T wink

     

    Found a solution:

    var nodeDzNode = Scene.getPrimarySelection();

    var nodeDzObj = nodeDzNode.getObject()

    var allProps = nodeDzObj.getPropertyGroups().getAllProperties();

    for (var i = 0; i < allProps.length; i++) {

    var prop = allProps[i];

    if(prop.isFavorite()) {

    var bake = new DzERCBake();

    bake.setControllerProperty(prop);

    bake.doBake()

    }

    }

    Post edited by Richard Haseltine on
  • gerster said:

    Richard Haseltine said:

    I'd add soem error-checking to the script, especially I would break down var modifier = nodeDzObj.getPropertyGroups().findPropertyByLabel( 'Morph name'); into separate steps and check that each strep of the process was giving a valid return.

    Yes, I already checked that one.
    findPropertyByLabel() returns the morph, I tested even reading the current value of the morph.

    However, the thing I don't get is:
    findPropertyByLabel() returns a value from from the type  DzProperty
    getControllerProperty()  expects a DzNumericProperty.

    property.getValueChannel();


    How can I utlize the result of findPropertyByLabel() for getControllerProperty()  ?

Sign In or Register to comment.