[BUG] Daz Studio 6 crash when using DzTransferUtility::getTargetOutputFigure()

Mike3DMike3D Posts: 87

Using DzTransferUtility::getTargetOutputFigure() method from script crashes Daz Studio 6.

Script to reproduce the crash :

(function(){

var tu = new DzTransferUtility();
tu.getTargetOutputFigure();

})();

 

Post edited by Mike3D on

Comments

  • Richard HaseltineRichard Haseltine Posts: 111,217

    Was theer a target figur0e (a figure selected in the scene)?

  • Mike3DMike3D Posts: 87

    Yes, and there's also a source figure, but the Transfer Utility, whether run from script or not, does not require any selection in the scene.

    Now, even if the scene is empty, Studio shouldn't crash, the method should simply return null.

  • umblefuglyumblefugly Posts: 162

    The problem seems to be that in DS6 it can crash if there is no valid output figure yet.

    A safer approach is to perform the transfer first, then reacquire the resulting figure from the scene instead of calling that getter:

    
     

    var tu = new DzTransferUtility();

     

    tu.setSource(sourceFigure);

    tu.setTarget(targetNode);

     

    if (tu.doTransfer()) {

     

    // Transfer Utility replaces the original target node,

    // so find the new live figure again in the scene.

    var nodes = Scene.getNodeList();

     

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

    if (nodes[i].getLabel() === targetLabel) {

    var outputFigure = nodes[i];

    print("Output figure: " + outputFigure.getLabel());

    break;

    }

    }

    }

    So instead of relying on:

    
     

    tu.getTargetOutputFigure();

    you can let the transfer complete and then locate the newly created figure in the scene. That's essentially how I've avoided needing that getter.

  • Mike3DMike3D Posts: 87

    Many thanks for your solution yes

    Actually we can simply do like that :

    var outputFigure;
    var tu = new DzTransferUtility();
    
    tu.setSource(sourceFigure);
    tu.setTarget(targetFigure);
    
    if (tu.doTransfer())
    	outputFigure = tu.getTargetOutputFigure();
    
    print(outputFigure.name);
    
  • umblefuglyumblefugly Posts: 162

    Mike3D said:

    Many thanks for your solution yes

    Actually we can simply do like that :

    var outputFigure;
    var tu = new DzTransferUtility();
    
    tu.setSource(sourceFigure);
    tu.setTarget(targetFigure);
    
    if (tu.doTransfer())
    	outputFigure = tu.getTargetOutputFigure();
    
    print(outputFigure.name);
    

    Glad it helped :D 

Sign In or Register to comment.