Quantcast
Channel: Adobe Community : Discussion List - After Effects Scripting
Viewing all 2143 articles
Browse latest View live

getting number of 3d layers in a selection

$
0
0

I've been trying variations of the follwing code -

 

var userSelection = app.project.activeItem.selectedLayers;
var num3d = [];

for (var j=0; j<userSelection.length; j++) num3d[j] = userSelection[j].threeDLayer= true;

alert (num3d.length)

 

I want to test an array of layers and execute and if else statement that alerts the user if some of the layers aren't 3d and does something else if the they are all three d layers.

 

Problem here (as far as I can gather) is that .threeDLayer = true sets the value instead of just retrieving it. I've also tried threeDLayer.value and that didn't work either.


updating dropdown when user selects.

$
0
0

I have a variable that takes a users selection with the following code. var userSelection = app.project.activeItem.selectedLayers;

 

I'd like this variable's array to change automatically if the user changes their selection in the composition. I'm not finding this in the documentation or online.

 

Thanks.

replaceWithPlaceholder method throwing char limit error

$
0
0

Hey Everyone,

 

Long time lurker first time poster...I wrote a script to replace my selected footage items with placeholders, but when i run it on footage items with particularly long names, I get an error:

 

"The String is too long, it can only be 31 bytes after conversion."

 

The script itself is below, any ideas on how to get around this limitation?  Running CC 12.2.1.5  Thanks!

 

app.beginUndoGroup("Convert Footage to Placeholders");


var proj = app.project;


var selectedItem = app.project.selection;
var numSelectedItems = selectedItem.length;


var defaultWidth = 1920;
var widthPromptText = "Placeholder Width"
var getwidth = prompt(widthPromptText, defaultWidth);
var width = parseInt(getwidth);


var defaultHeight = 1080;
var heightPromptText = "Placeholder Height"
var getheight = prompt(widthPromptText, defaultHeight);
var height = parseInt(getheight);




for (var i = 1; i <= proj.numItems; i++) {          if (proj.item(i).selected) {                    var theItem = proj.item(i);                    var itemName = theItem.name;                    //alert(itemName); //works just fine, i get the names just fine                    var compFR = theItem.frameRate;                    var compDuration = theItem.duration;                    proj.item(i).replaceWithPlaceholder(itemName, width, height, compFR, compDuration);          }
}




alert("all done");

Finding Start Time of Footage

$
0
0

I'm trying to get the starting timecode of footage via scripting. The only way I can think of doing this is using the "New Comp from Selection" app.executeCommand to create a comp. Then I can use displayStartTime function on the new comp. Is there a smarter way to do this? I'd rather not use the app.executeCommand but I can't think of anything else. If there isn't a better way, could someone tell me why the script below isn't working? It does the first loop but after that the remaining loops don't execute fully. Thanks for the help!

 

--

 

var selectedFootage = app.project.selection;

var footageComps = new Array();

var startTimes = new Array();

 

 

for (var i=0; i<selectedFootage.length; i++)

{

 

 

          // Deselect All

          app.executeCommand(2004);

 

 

          // Select Footage Item

          selectedFootage[i].selected = true;

 

 

          // New Comp From Selection

          app.executeCommand(2796);

 

 

          // Deselect Footage Item

          selectedFootage[i].selected = false;

 

 

          // Set footageComps Varible

          footageComps[i] = app.project.activeItem;

 

 

          // Get Start Time

          startTimes[i] = footageComps[i].displayStartTime;

          alert(startTimes[i]);

 

 

}

How to get the startTime attribute to line up layers on whole frames

$
0
0

I'm trying to use startTime to position layers in time. When trying to do this in comps at non-whole framerates such as 23.976 or 29.97 then the layers never quite align properly to the whole frame. for example with...

 

app.project.item(index).layer(index).startTime = 2;

 

the layer will sit between the 01:29s and 02:00s. Any ideas how to fix this?

 

Thanks!

updating dropdown list

$
0
0

Hi have a dropdownlist that takes its content from a users layer selection in the timeline when the script is run. However, I'd like the dropdownlist to update if the user makes a new selection.ie. The user has layers 1. 2, 3, 4 selected and runs the script. After running the script they change the selection to just 2, 4. Can I script this to update automatictally? Failing that could create a button to reset the dropdown list?

 

Here are the relevent bits of my code.

 

//create variable and extract .name property. Place in selectionNames variable

var userSelection = app.project.activeItem.selectedLayers;    

var selectionNames = [];

for (var j=0; j<userSelection.length; j++) selectionNames[j] = userSelection[j].name;

//average is added to all selectedLayers

selectionNames.push("Average");

 

myDropDownList:DropDownList{properties:{items:" + selectionNames.toSource() + "}}\

 

//loads dropdownlist selection into variable after user selection

var num = 0;
    myScriptPal.grp.groupOne.myPanelTwo.myDropDownList.onChange = function () {
        var ddListSelection = myScriptPal.grp.groupOne.myPanelTwo.myDropDownList.selection
   alert (ddListSelection.index); 
              alert (userSelection[ddListSelection.index].position.value[dimension]);
              num = userSelection[ddListSelection.index].position.value[dimension];
   }

 

 

I can post more of my script if this doesn't make thing clear.

Possible to execute code after project finishes loading?

$
0
0

Hi There,

 

Is there a way to execute code immediately after AE has completed loading a project?

 

 

Thanks,
Arie

switch case: Must use string value?

$
0
0

in the example below I have two items in a switch case. The first one works and the second doesn't. In the second one I tried using a variable to concatinate the string for the case. For some reason as soon as I do this it doesn't locate the second case. It seems like it should work...

 

 

for (c = 1; c<= numItems; c++) {

    var comp = app.project.items[c];

    var scale = 100;

 

 

    if (comp instanceof CompItem) {                                  

 

 

        for (i = 1; i <= comp.numLayers; i++) {                       

           

            switch(comp.layer(i).name) {

                                            

               case "textLines_NFLAM":  //This one works

                    targetWidth = 1400;

                    comp.layer(i).scale.setValue ([scale, scale]);

                    setTextLayer_caseSensitive(comp.layer(i), lineValue);

 

 

                    if(scaleTextLayer(comp.layer(i), comp.layer(i).sourceRectAtTime(1, true).width, targetWidth)){

                        modifiedLayers.push(comp.layer(i));

                    }                          

                break;

               

               

               var showName = "TA";

               

                case "textLines_" + showName:     //This one doesn't work unless I change it to:  case "textLines_TA":

                    targetWidth = 1430;

                    comp.layer(i).scale.setValue ([scale, scale]);

                    setTextLayer_caseSensitive(comp.layer(i), lineValue);

 

 

                    if(scaleTextLayer(comp.layer(i), comp.layer(i).sourceRectAtTime(1, true).width, targetWidth)){

                        modifiedLayers.push(comp.layer(i));

                    }                           

                break;

            }

        }

    }

}


Script 'Working Space' - sRGB

$
0
0

Is there a way to set working space via script.  Ultimately I want to set it to sRGB.  I've found attributes on the project object for linear blending and 32 bits, but not working space.

 

Thanks,

 

Justin

Loading “external library” get “I/O error” in mac

$
0
0

I just discovered the "external library" in extendscript. So I opened up the "samplelib" example in Xcode 5, update the base sdk to 10.9 and buit it(the project file is very old, it's for xcode 2.4 and mac os x 10.4). There was no error in the building process. But, when I tried to run the script, I keep getting the "I/O error" at line "var sampleLib = new ExternalObject("lib:" + libPath);" . I tried to change the "SampleLib.framework" file to readable and writable for every user, but it didn't help.

 

So, guys, any idea what I've been doing wrong?

 

Thanks!!!

Is it possible to loop through items/layers and change the color overlay?

$
0
0

Is it possible to loop through items/layers and change the color overlay? I can get select layers but am unsure how to loop through and change the color overlay.

 

I am using

app.executeCommand(app.findMenuCommandId("Color Overlay"));

overlay.layerStyle.colorOverlay.color.setValue(10);

 

to change other properties but on Overlay it simply fails.

Possible to script the curves effect?

$
0
0

Hello,

 

I'm wondering if it's possible to script the curves effect.  I get a 'property not implemented' error when I attempt to do so.  I'm guessing this is because this effect has no scripting interface yet, but just want to double check.

 

Thanks,

 

Justin

Looping through layers and selecting layer by name?

$
0
0

I am trying to find a layer by name and loop through the selections.

 

function projectItem(name)

{

          var items = app.project.items;

          i = 1;

          while (i <= items.length) {

                              if (items[i].name == name)

                              {

                                        return app.project.item(i);

                                        break;

                              }

                              i++;

                    }

}

 

This works right?

ExtendScript Toolkit - Object Model Viewer

$
0
0

Hi all,

 

I know there's not really a way around this but I'm curious if anyone knows why the Object Model Viewer in ExtendScript Toolkit doesn't have After Effects Object Model in the Browser dropdown?  It has it for Bridge, InDesign, Illustrator and Photoshop. 

 

Not that jumping into the AE Scripting Guide is much of a pain...but it just seems like it would be appropriate to have it inside ESTK...

checking perf of a function or anything else

$
0
0

Is there a way to check how long a function takes to execute? maybe some type of timer? or maybe getting the system time before and after the function and subtracting the two values? Overall I am just curious how people check their script performance.


How can I duplicate a FootageItem object via scripting?

$
0
0

Hi There,

 

I am trying to understand why I cannot duplicate a FootageItem object in the same manner as a CompItem object.  For example, if I am iterating through a composition and encounter a layer that is of type CompItem, I can do this:

 

dupe = layer.source.duplicate()

 

. . . and with that, I will get a duplicate of the layer's source (a composition) in the project panel. 

 

However, if I encounter a layer that is of type FootageItem, then I cannot use the .duplicate() method.  Using the same code above, ESTK gives me this error on a layer with a source type of FootageItem

 

Error: Function l.source.duplicate is undefined

 

What is the necessary code to duplicate a FootageItem?

 

I want to understand how I can duplicate a footage item that is used for a layer.  I do not want to duplicate the layer itself, but its source.

 

Thanks for your time and help!

 

--Arie

Multiline text alignment in UI

$
0
0

Hi guys. Newby here. Sorry if this is silly questtion, but I am getting bold solving this with no prevail.

 

I have a multiline text. But it's aligned to the left. Any way to center align it?

 

<CODE>

var aboutWin = new Window("palette", "About", undefined);

var st = aboutWin.add("statictext", undefined, "", {multiline: true } );

st.text = "Some long long long text paragraph here";

st.characters = 30;

</CODE>

 

How do I center align it?

 

Thank you.

Choose new active layer?

$
0
0

How do you choose a new active item?

 

item(1).select?

 

or is there a different script?

remove ListBox item's icon?

$
0
0

I'm trying to remove the listbox item's icon or image, but nothing seems to work?! What am I doing wrong?

 

    var w = new Window ("window");
    lb = w.add ("listbox", [0,0,100,150], ["item1", "item2", "item3"]);
    var btn = w.add ("button");
   
    lb.items[1].icon = File ("~/Desktop/redSquare.jpg");
   
    // None of this is working...
    btn.onClick = function (){
        lb.items[1].icon.remove();
        lb.items[1].image.remove();
        lb.items[1].remove("icon");
        lb.items[1].remove("image");
        lb.remove("image", items[1]);
        lb.remove("icon", items[1]);
        lb.remove(items[1].icon);
        lb.remove(items[1].image);
        }
   
    w.show();

Saving plain text on a mac (Keyboard shortcuts file)

$
0
0

Hi there perhaps some mac users can help me...

 

I am manually editing the keyboard shortcuts file in TEXT edit on a mac (Im a pc user). I open the file as plain text  all the rich text stuff turned off.

(Looked up how to do this.)

I edit one of the shortcuts, no unusual characters etc.

 

When I restart CC, it gives an error and shows squiggley characters at that line as the problem.

 

On a pc I just edit and save as plain text and there are no issues...

What am I doing wrong on a mac in Text edit ?

 

Thanks Alan.

Viewing all 2143 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>