AE ENHANCERS

Expressions/Scripts/Presets
It is currently Tue May 21, 2013 10:03 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Put nulls at each corner of a solid
PostPosted: Fri Jun 15, 2012 11:44 am 
Offline

Joined: Mon Feb 16, 2009 12:41 pm
Posts: 59
Not much more to explain.

For every Solid I have selected (2D or 3D), put a null in each corner. :D


Top
 Profile  
 
 Post subject: Re: Put nulls at each corner of a solid
PostPosted: Fri Jun 15, 2012 1:07 pm 
Offline

Joined: Fri Jul 23, 2010 11:49 pm
Posts: 29
Try the attached script.

Code:
// CornerNulls.jsx by Dan Fredley ©2012
// Version 1.0
// This script creates a null object at each corner of selected layers and keeps them organized in a "Nulls" folder within the "Solids" folder.
//
// No scripts are guaranteed and use at your own risk, etc.
{
    function CornerNulls ()
    {
        app.beginUndoGroup("CornerNulls");    // create script undo group
        var proj = app.project;
        var comp = proj.activeItem;
        var layer, len, myNull, solidsFolder, nullsFolder, item, myNull1, myNull2, myNull3, myNull4, nullDuration;
        var foundSolids = foundNullsFolder = false;
        var myItemCollection = app.project.items;
        var sel = new Array();
        var compNulls = [];
     
        if (!(comp instanceof CompItem)) {
            alert("Please select a composition.");
            return;
        } else if (comp.selectedLayers.length < 1) {
            alert("Please select at least one layer.");
            return;
        } else {
          sel = comp.selectedLayers;
          nullDuration = comp.duration;  // change to the number of seconds or comp.duration for length of comp
        }
        for (i=1;i<=proj.numItems;i++){  //loop through project items to find solids folder
          item = myItemCollection[i];
            if (item.name == 'Solids' && item instanceof FolderItem && item.parentFolder == app.project.rootFolder){
                foundSolids = true;
                solidsFolder = item;
                break;
            }
        }
        if (foundSolids) {
            for (i=1;i<=solidsFolder.numItems;i++){ // loop through solidsFolder to find Nulls folder and null object
                item = solidsFolder.items[i];
                if (item.name == "Nulls" && item instanceof FolderItem){  //  look for Nulls folder
                    foundNullsFolder = true;
                    nullsFolder = item;
                    continue;
                }
            }
        } else {
            solidsFolder = proj.items.addFolder('Solids');
        }
        if (!foundNullsFolder) nullsFolder = solidsFolder.items.addFolder('Nulls'); // if no nulls folder was found create one   
        for (i=0, len = sel.length; i < len; i++){  //loop through selected layers
          layer = sel[i].name;
         
          myNull1 = comp.layers.addNull(nullDuration);
          myNull1.parent = sel[i];
          myNull1.position.expression = """[0,0]""";
          myNull1.name = sel[i].name + " TL";
          myNull1.source.parentFolder = nullsFolder;
          myNull1.moveBefore(sel[i]);
          myNull1.inPoint = sel[i].inPoint;
          myNull1.outPoint = sel[i].outPoint;
          myNull1.threeDLayer = sel[i].threeDLayer;
         
          myNull2 = comp.layers.addNull(nullDuration);
          myNull2.parent = sel[i];
          myNull2.position.expression = 'L=thisComp.layer("' + sel[i].name + '");\r[L.width,0]';
          myNull2.name = sel[i].name + " TR";
          myNull2.source.parentFolder = nullsFolder;
          myNull2.moveBefore(sel[i]);
          myNull2.inPoint = sel[i].inPoint;
          myNull2.outPoint = sel[i].outPoint;
          myNull2.threeDLayer = sel[i].threeDLayer;         
         
          myNull3 = comp.layers.addNull(nullDuration);
          myNull3.parent = sel[i];
          myNull3.position.expression = 'L=thisComp.layer("' + sel[i].name + '");\r[L.width,L.height]';
          myNull3.name = sel[i].name + " BR";
          myNull3.source.parentFolder = nullsFolder;
          myNull3.moveBefore(sel[i]);
          myNull3.inPoint = sel[i].inPoint;
          myNull3.outPoint = sel[i].outPoint;
          myNull3.threeDLayer = sel[i].threeDLayer;         
         
          myNull4 = comp.layers.addNull(nullDuration);
          myNull4.parent = sel[i];
          myNull4.position.expression = 'L=thisComp.layer("' + sel[i].name + '");\r[0,L.height]';
          myNull4.name = sel[i].name + " BL";
          myNull4.source.parentFolder = nullsFolder;
          myNull4.moveBefore(sel[i]);
          myNull4.inPoint = sel[i].inPoint;
          myNull4.outPoint = sel[i].outPoint;
          myNull4.threeDLayer = sel[i].threeDLayer;         
        }
        app.endUndoGroup();
    }
    CornerNulls();
}


Attachments:
File comment: // CornerNulls.jsx by Dan Fredley ©2012
// Version 1.0
// This script creates a null object at each corner of selected layers and keeps them organized in a "Nulls" folder within the "Solids" folder.
//
// No scripts are guaranteed and use at your own risk, etc.

CornerNulls.jsx.zip [1.27 KiB]
Downloaded 48 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group