Collect Files - scriptable?

Community Beginner ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Hi everyone,

 

I'm working on an upload plugin to send an AE project and it's assets to another system.

 

Does anyone know if the "File -> Dependencies -> Collect Files..." funcitonality is accessible through ActionScript? I see the consolidateFootage() and reduceProject() methods available on the app.project object but don't know if Collect Files is exposed anywhere.

 

Any advice would be greatly appreciated.

 

Thanks!

 

Harry

TOPICS
Import and export , Scripting , User interface or workspaces

Views

316

Likes

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

correct answers 1 Correct answer

Adobe Community Professional , Sep 14, 2020 Sep 14, 2020
As far as I know, it is not exposed to scripting, unfortunately. So as Mylenium suggested, you can execute the menu command, but this will only open the dialog. The only other - very tedious - option is to implement it yourself.

Likes

Translate

Translate
Adobe Community Professional ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

The command itself may easily be scriptable through the executeMenuCommand() function, but I'm not certain if the various sub-options on the dialog panel can be set this way. This stuff tends to be rather inconsistent.

 

Mylenium

Likes

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
Adobe Community Professional ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

As far as I know, it is not exposed to scripting, unfortunately. So as Mylenium suggested, you can execute the menu command, but this will only open the dialog. The only other - very tedious - option is to implement it yourself.

Likes

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 Beginner ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Thanks Mylenium and Mathias, it seems you're both spot on, executing the below opens the dialog:

app.executeCommand(2482);

but I can't interact with it through code.

 

Thanks for the advice, time to look into relinking assets manually.

 

Harry 

Likes

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
Adobe Community Professional ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Exporting a MoGRT (from the Essential Graphics Panel) invokes the Collect Files routine - it's a 2-in-1 thingy. You end up with a MoGRT instead of an AEP. You can then open the MoGRT in AE. The only downside is that you won't be able to IMPORT the MoGRT into an existing AEP without first opening it and then resaving it as an AEP. You can of course do all of this prior to sending out the files and hence, only send an AEP. And MoGRT export is scriptable.

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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
Adobe Community Professional ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

Wow, that's a clever workaround, Roland!

Likes

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
Adobe Community Professional ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

Only the BEST for you my friend. 🙂

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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 Beginner ,
Sep 16, 2020 Sep 16, 2020

Copy link to clipboard

Copied

Hi Roland,

 

Thats ingenius, as you say the comp.exportAsMotionGraphicsTemplate() function lets me bundle up everything into a .mogrt file, what an idea!

 

Apologies for the delayed response, I've been trying to open the template and resave it as an AEP but hit another wall. When opening the file from the GUI, AE brings up a promp to "Extract .MoGrt into folder," I don't suppose you know if this is scriptable too? 

 

Running the standard app.open() command seems promising but returns an undefined as I guess it doesn't know how to handle that extract process.

 

It might be too much to hope for, thanks for your suggestion so far anyway!

Likes

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
Adobe Community Professional ,
Sep 16, 2020 Sep 16, 2020

Copy link to clipboard

Copied

It's a good thing you reported back cos I recall a *.mogrt file is essentially a ZIP package.

 

Try these steps. Rename the *.mogrt file as *.zip and unpack it. You'll end up with a *.aegraphic file. Then, again rename the *.aegraphic as *.zip and unpack this. And VOILA! You'll end up with a functional *.aep!

 

I'll send you an invoice tomorrow!
😄

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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 Beginner ,
Sep 16, 2020 Sep 16, 2020

Copy link to clipboard

Copied

Roland thank you very much, that seems to do the trick!

 

Thanks again all, your expertise is very much appreciated!

 

Harry

Likes

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 Beginner ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

So did you ever make this script? I would be very interested in it if you did.

Likes

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 Beginner ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

LATEST

You'll have to forgive me, we wrote this 18 months ago now and I don't think we actually ended up using it in production.

 

From what I remember, we had to provide a "head comp" for the mogrt export to work properly, and the template export would only bundle up assets used directly in that head comp, not the entire project.

 

Give the it a try though, curious to know if it'll work for other people!

 

(just a note, the below won't run without a reference to a JSON object, google around for "json in extendscript" for tips on how to do it, I think we ended up using douglascrockford's JSON-js in particular: https://github.com/douglascrockford/JSON-js/blob/master/json2.js )

 

Happy exporting!

function getCompByName(compName) {
    for (var i = 1; i <= app.project.numItems; i ++) {
        if (app.project.item(i) instanceof CompItem && app.project.item(i).name === compName) {
            myComp = app.project.item(i);
            break;
        }
    }
    return myComp;
}

$._ext.SaveMOGRT = function(compName, exportedFileName, mogrtFilePath) {

    //get the head comp
    var AA_mainComp = getCompByName(compName);
    var saveresult = {
        savedsuccessfully: false,
        filename: "",
        errors: []
    };

    try {

        //count if there are any motion graphics controllers in the comp
        if (AA_mainComp.motionGraphicsTemplateControllerCount == 0) {
            //if no, create a new null object
            AA_mainComp.layers.addNull();
            var AA_SelectedLayer = AA_mainComp.layers[1];
            AA_mainComp.openInEssentialGraphics();
            
            //check if the null's position can be added to the motion graphics controllers, add it if so
            if (AA_SelectedLayer.position.canAddToMotionGraphicsTemplate(AA_mainComp)) {
                if (!AA_SelectedLayer.position.addToMotionGraphicsTemplate(AA_mainComp)) {
                    saveresult.errors.push("failed to add null position property to motion graphics controllers");
                }
            } else {
                saveresult.errors.push("could not add null position property to motion graphics controllers");
            }
            
        }

    } catch (error) {
        saveresult.errors.push(JSON.stringify(error));
    }

    if (saveresult.errors.length == 0){

        try {
            //saveMogrt
            AA_mainComp.motionGraphicsTemplateName = exportedFileName;

            //create local temp folder for MOGRT
            if (!Folder("C:\\temp\\TemplateUploadStaging").exists) {
                Folder("C:\\temp\\TemplateUploadStaging").create();
            }
            var tempSavePath = "C:\\temp\\TemplateUploadStaging\\" + exportedFileName + ".mogrt";

            if (AA_mainComp.exportAsMotionGraphicsTemplate(true, tempSavePath)) {
                $.writeln("saved successfully");
                //copy from temp location to uploads directory
                var tempFile = new File("C:\\temp\\TemplateUploadStaging\\" + exportedFileName + ".mogrt\\" + exportedFileName + ".mogrt");
                
                if (!Folder(mogrtFilePath).exists) {
                    Folder(mogrtFilePath).create();
                }
        
                tempFile.copy(mogrtFilePath + "\\" + exportedFileName + ".mogrt");
                
                saveresult.filename = app.project.file.toString();
                saveresult.savedsuccessfully = true;
            } else {
                saveresult.errors.push("failed to exportMOGRT");
            }

        } catch (error) {
            saveresult.errors.push(JSON.stringify(error));
        }
    }

    return JSON.stringify(saveresult);

}

 

Likes

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