Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scripting: The default Solids Folder

  • Scripting: The default Solids Folder

    Posted by Andy Kreutzberg on May 7, 2013 at 2:02 pm

    Hi all,

    i hope the subforum is correct for my question.

    I am tinkering around with scripting and already managed to create some nice stuff. However, there is one thing that currently puzzles me: The Solids folder that after effects automatically creates when a solid is added and it realizes that there is no Solids folder in the root of the project.

    This folder is sort of problematic for what i am trying to achieve. All new solids that are created are supposed to be moved into a sub folder in the project. Here is a bit of the code:

    app.beginUndoGroup("solidtest1");

    var myItemCollection = app.project.items;
    var compN = "MasterName";
    var compBG = [0/255,0/255,0/255];
    var compL = 12;
    var packtemplate_show01 = myItemCollection.addComp(compN,1920,1080,1,compL,25);
    packtemplate_show01.bgColor = compBG;
    packtemplate_show01.hideShyLayers = true;

    var TitleBottomLines = packtemplate_show01.layers.addSolid([255/255, 255/255, 255/255], "TitleBottomLines", 1920, 1080, 1, 12);

    footageFolder = app.project.items.addFolder("Footage");
    footageSubFolder1 = app.project.items.addFolder("Images");
    footageSubFolder2 = app.project.items.addFolder("Master");
    compFolder = app.project.items.addFolder("compFolder");
    footageSubFolder1.parentFolder = footageFolder;
    footageSubFolder2.parentFolder = footageFolder;
    footageFolder.parentFolder = compFolder;

    for (var i = 1; i<=app.project.numItems; i++) {
    if(app.project.item(i) instanceof CompItem)
    app.project.item(i).parentFolder = compFolder}

    var SolidsFolder = app.project.item(6);

    TitleBottomLines.parentFolder = footageSubFolder1;

    alert(TitleBottomLines.parentFolder.name + " " + SolidsFolder.index);

    app.endUndoGroup();

    The line that defines the subfolder for the previously created solid “TitleBottomLines” is not working. The solid remains in the default Solids folder though when i alert the .name property of the solids parent folder at the end of the script, it will alert the name of the subfolder “images”. Why is it not being moved into this folder then?

    I found some other weird things about the default Solids folder. The alert for the index of this folder returns undefined even though the index was identified as 6.

    Is there some magic involved to move solids out of this folder or did i just misunderstood something? Not sure if you guys can help me with this. I might also ask this at the enhancers forum once my account there is activated.

    Andy Kreutzberg replied 13 years ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    May 7, 2013 at 2:16 pm

    I think you’re trying to move a solid layer into your folder, instead of the solid’s source. Try this instead:

    TitleBottomLines.source.parentFolder = footageSubFolder1;

    Dan

  • Andy Kreutzberg

    May 7, 2013 at 2:23 pm

    Dan, you are a lifesaver! Thanks a million!

    I never would have thought about the .source attribute. The scripting guide can be a bit confusing when it comes to these things. I have looked endlessly through it and did not really find what you just pointed out (could not see the forest because of all the trees i guess).

  • Andy Kreutzberg

    May 7, 2013 at 2:47 pm

    Just maybe another question in relation to this. I added a line to remove the empty solids folder. It goes like this:

    var SolidsFolder = app.project.item(6);
    SolidsFolder.remove();

    Now the problem is that when i run the script multiple times, the default solids folder will only be removed after the first time i ran the script. After the second time, my composition will be removed instead. I suppose this is because the new layers created by the script add up to the previously existing layers and thus having different index numbers, making the line…

    var SolidsFolder = app.project.item(6);

    …refer to my main composition instead. Is there a workaround for this so that at the end of the script, the empty default solid folder will be removed each time the script is executed? I suppose this would happen with a function?

  • Andy Kreutzberg

    May 7, 2013 at 3:21 pm

    The answer to my own question above:

    for (var i = 1; i<=app.project.numItems; i++) {
    if(app.project.item(i) instanceof FolderItem& app.project.item(i).numItems==0)
    app.project.item(i).remove()}

    This will remove any empty folders in the project window.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy