• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Change render location function not working

Explorer ,
Sep 08, 2022 Sep 08, 2022

Copy link to clipboard

Copied

I have this function to change the render locations on the items in the queue. I can't get it to work however. I'm getting the file path either from the preferences or by asking the user to choose a new location before this function is run. My script does not seem to trigger the function because I don't see the alert dialogs that I have in there. 

function ChangeRenderLocations(newLocation) {
    var newLocation = Folder.selectDialog("Select a render output folder...");
    alert("changing render location to: " + newLocation);

    if (newLocation != null) {

        // Process all render queue items whose status is set to Queued.
        for (var i = 1; i <= app.project.renderQueue.numItems; ++i) {
            var curItem = app.project.renderQueue.item(i);

            //if (curItem.status == RQItemStatus.QUEUED) {
                // Change all output modules for the current render queue item.
                for (var j = 1; j <= curItem.numOutputModules; ++j) {
                    var curOM = curItem.outputModule(j);

                    var oldLocation = curOM.file;
                    curOM.file = new File(newLocation.fsName + "/" + curItem.comp.name);

                    alert("New output path:\n" + curOM.file.fsName, scriptName);
                }
            //}
        }

    } else {
        var newLocation = Folder.selectDialog("Select a render output folder...");
    }
}

 

This function is triggered by this portion of my script:

    var renderFolder = new Folder(myScriptPal.grp.groupOne.groupSettings.btn_resetOutput.helpTip);
    consoleLog("Finished building, now wrapping up...");

    //change render locations
    if (renderFolder != null) {
        consoleLog("Render folder checked out, setting render queue up now.")
        ChangeRenderLocations(renderFolder)
    } else {
        consoleLog("Render folder did not check out. Asking the user for a new one.")
        var newLocation = Folder.selectDialog("Select a render output folder...");
        ChangeRenderLocations(newLocation);
    }
TOPICS
Scripting

Views

73

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 30, 2023 Jan 30, 2023

Copy link to clipboard

Copied

LATEST

You'll want to break this down piece by piece to find the issue when debugging.

 

Only issue I could find was your alert trying ton add a string and a File which isn't always relibale without first converting the file to a string or getting the fsname. Also your variable scriptName was undefined.

 

This seems to work:

 

    var newLocation = Folder.selectDialog("Select a render output folder...");
    alert("changing render location to: " + newLocation.fsName);
    if (newLocation != null) {
        for (var i = 1; i <= app.project.renderQueue.numItems; ++i) {
            var curItem = app.project.renderQueue.item(i);
                for (var j = 1; j <= curItem.numOutputModules; ++j) {
                    var curOM = curItem.outputModule(j);

                    var oldLocation = curOM.file;
                    curOM.file = new File(newLocation.fsName + "/" + curItem.comp.name);

                    alert("New output path:\n" + curOM.file.fsName, 'scriptName');
                }
        }

    } else {
        var newLocation = Folder.selectDialog("Select a render output folder...");
    }

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines