Trying to run a custom script for batch rendering, without sucess so far.

I'm trying to create a batch render script to speed up my workflow, but I have very little experience with Java, much less using it with Daz3D.
Can some spot anything wrong with the script I came up with?

 

// CustomRenderQueue.dsa

// Batch Render UI for Daz Studio

 

var win = new DzDialog;

win.caption = "Batch Render Queue";

 

// Queue and variables

var sceneQueue = [];

var currentSceneIndex = 0;

var renderSettingsPath = "";

var renderMode = "Still"; // or "Animation"

var settleTime = 5;

var killTime = 60;

 

// === UI Layout ===

var layout = new DzVBoxLayout(win);

 

// SCENE QUEUE LIST

var queueLabel = new DzLabel(win);

queueLabel.text = "Scene Queue:";

layout.addWidget(queueLabel);

 

var queueList = new DzListBox(win);

queueList.minimumHeight = 100;

layout.addWidget(queueList);

 

var addSceneBtn = new DzPushButton(win);

addSceneBtn.text = "Add Scene (.duf)";

layout.addWidget(addSceneBtn);

 

// RENDER SETTINGS PATH

var settingsLabel = new DzLabel(win);

settingsLabel.text = "Render Settings File:";

layout.addWidget(settingsLabel);

 

var settingsPathBox = new DzLineEdit(win);

settingsPathBox.readOnly = true;

layout.addWidget(settingsPathBox);

 

var selectSettingsBtn = new DzPushButton(win);

selectSettingsBtn.text = "Choose Render Settings...";

layout.addWidget(selectSettingsBtn);

 

// RENDER MODE

var modeLabel = new DzLabel(win);

modeLabel.text = "Render Mode:";

layout.addWidget(modeLabel);

 

var modeDropdown = new DzComboBox(win);

modeDropdown.addItem("Still");

modeDropdown.addItem("Timeline");

layout.addWidget(modeDropdown);

 

// SLIDERS

function addSlider(labelText, min, max, value) {

var container = new DzHBoxLayout();

var label = new DzLabel(win);

label.text = labelText;

container.addWidget(label);

 

var slider = new DzSlider(win);

slider.minimum = min;

slider.maximum = max;

slider.value = value;

container.addWidget(slider);

 

layout.addLayout(container);

return slider;

}

 

var settleSlider = addSlider("Settle Time (s):", 0, 60, 5);

var killSlider = addSlider("Kill Timeout (s):", 10, 300, 60);

 

// START BUTTON

var startBtn = new DzPushButton(win);

startBtn.text = "Start Rendering";

layout.addWidget(startBtn);

 

// === BUTTON CALLBACKS ===

addSceneBtn.clicked.connect(function () {

var file = FileDialog.doFileDialog("Choose Scene File", "", "*.duf");

if (file) {

sceneQueue.push(file);

queueList.addItem(file);

}

});

 

selectSettingsBtn.clicked.connect(function () {

var file = FileDialog.doFileDialog("Choose Render Settings", "", "*.duf");

if (file) {

renderSettingsPath = file;

settingsPathBox.text = file;

}

});

 

startBtn.clicked.connect(function () {

if (sceneQueue.length === 0) {

MessageBox.information("No scenes in queue.");

return;

}

 

renderMode = modeDropdown.currentText;

settleTime = settleSlider.value;

killTime = killSlider.value;

 

renderNextScene();

});

 

// === RENDERING LOGIC ===

function renderNextScene() {

if (currentSceneIndex >= sceneQueue.length) {

MessageBox.information("All scenes rendered!");

return;

}

 

var sceneFile = sceneQueue[currentSceneIndex];

App.loadScene(sceneFile);

 

if (renderSettingsPath !== "") {

App.applyRenderSettings(renderSettingsPath);

}

 

Timer.startTimer(settleTime * 1000, function () {

if (renderMode === "Timeline") {

App.renderTimeline();

} else {

App.render();

}

 

Timer.startTimer(killTime * 1000, function () {

callRestart();

});

});

}

 

function callRestart() {

var batFile = new DzProcess;

var batPath = App.getAbsolutePath("RestartDaz.bat");

if (batPath) {

batFile.start(batPath);

}

App.quit();

}

 

// === OPEN WINDOW ===

win.exec();

 

The only error I get when I run is this:

Executing Script...
\src\sdksource\general\dzscript.cpp(1192): Unhandled error while executing script.
Result: 
Script executed in 0 secs 7 msecs.

Does anyone know what I am doing wrong?

Comments

  • CES3DCES3D Posts: 228

    You need to modify the code within the function addSlider.

    The DzHBoxLayout constructor requires a parent widget or layout as an argument.
    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/hboxlayout_dz

    DzSlider is an abstract class and cannot be instantiated.
    Please instantiate its derived class, such as DzIntSlider (or DzFloatSlider).
    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/slider_dz

    Insert print statements or terminate the script as needed to identify where the error occurs.

    // SLIDERS
    function addSlider(labelText, min, max, value) {
        var container = new DzHBoxLayout(layout);   // argument added
        var label = new DzLabel(win);
        label.text = labelText;
        container.addWidget(label);
    
        var slider = new DzIntSlider(win);          // DzSlider -> DzIntSlider
        slider.minimum = min;
        slider.maximum = max;
        slider.value = value;
        container.addWidget(slider);
    
        // Since the Parent is specified in the DzHBoxLayout constructor, I think this line is unnecessary.
        // layout.addLayout(container);
        return slider;
    }

    My suggested fixes ensure the dialog appears without errors, but I haven't verified if the subsequent behavior aligns with your intended functionality.

  • mjanuario007mjanuario007 Posts: 0

    CES3D said:

    You need to modify the code within the function addSlider.

    The DzHBoxLayout constructor requires a parent widget or layout as an argument.
    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/hboxlayout_dz

    DzSlider is an abstract class and cannot be instantiated.
    Please instantiate its derived class, such as DzIntSlider (or DzFloatSlider).
    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/slider_dz

    Insert print statements or terminate the script as needed to identify where the error occurs.

    // SLIDERS
    function addSlider(labelText, min, max, value) {
        var container = new DzHBoxLayout(layout);   // argument added
        var label = new DzLabel(win);
        label.text = labelText;
        container.addWidget(label);
    
        var slider = new DzIntSlider(win);          // DzSlider -> DzIntSlider
        slider.minimum = min;
        slider.maximum = max;
        slider.value = value;
        container.addWidget(slider);
    
        // Since the Parent is specified in the DzHBoxLayout constructor, I think this line is unnecessary.
        // layout.addLayout(container);
        return slider;
    }

    My suggested fixes ensure the dialog appears without errors, but I haven't verified if the subsequent behavior aligns with your intended functionality.

    My friend, thanks for the help. Though I'm still far from perfecting the script, it fixed the issue.
    Also thanks for pointing out the documentation site, it was very instructive!

  • mjanuario007mjanuario007 Posts: 0

    CES3D said:

    You need to modify the code within the function addSlider.

    The DzHBoxLayout constructor requires a parent widget or layout as an argument.
    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/hboxlayout_dz

    DzSlider is an abstract class and cannot be instantiated.
    Please instantiate its derived class, such as DzIntSlider (or DzFloatSlider).
    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/slider_dz

    Insert print statements or terminate the script as needed to identify where the error occurs.

    // SLIDERS
    function addSlider(labelText, min, max, value) {
        var container = new DzHBoxLayout(layout);   // argument added
        var label = new DzLabel(win);
        label.text = labelText;
        container.addWidget(label);
    
        var slider = new DzIntSlider(win);          // DzSlider -> DzIntSlider
        slider.minimum = min;
        slider.maximum = max;
        slider.value = value;
        container.addWidget(slider);
    
        // Since the Parent is specified in the DzHBoxLayout constructor, I think this line is unnecessary.
        // layout.addLayout(container);
        return slider;
    }

    My suggested fixes ensure the dialog appears without errors, but I haven't verified if the subsequent behavior aligns with your intended functionality.

    Thank you, you helped more than you imagine. I completely forget about the documentation, so thanks for the links too.

     

Sign In or Register to comment.