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

Some insight in finding and placing specific items in a specific folder

$
0
0

Hello Community,

 

I have tried to find  a script ( or parts of scripts) where I can find items, using only a part of the name / a specific word inside that item.
So that later on I can place that selected file inside a specific folder.


Could you help me out?

 

 

 

In this particular case, I would like to find a solution in code to select all layers with "Alpha", "ALPHA" and "alpha" somewhere in it's name, and arrange it in the folder named "06_COMPS".

 

 

 

The closest I manage to get is a not working script:

 

         

function main(){

   

   

var myProject = app.project.items;

var nom= app.project.item(1).name

 

var SelectItem = app.project.activeItem

var nameItem =  app.project.activeItem.name

 

var theName

                 

  function findFolder(theName){

    for (var i = 1; i <= app.project.numItems; i++){

      if (app.project.item(i) instanceof FolderItem && app.project.item(i).name == theName){

        return app.project.item(i);

      }

    }

    return null;

  }

var folderItem = findFolder("06_COMPS");

  if (folderItem == null){

    return;

  }

 

 

var myItemFolder = findFolder(nameItem + "Alpha");

  if (myItemFolder == null){

    return;

  }

 

myItemFolder.parentFolder = folderItem;

SelectItem.parentFolder = folderItem

 

}

         

main()

 

 

Here is the example in image:

javascript_question_placing files_into_folder.jpg

 

 

If you guys know a work around this code or you have a solution, please tell me,
the try-outs (cut and pasting parts of codes I found on the net from different sources) have been only confusing me even more.

 

 

 

Much appreciated,

 

Marc


Correct layer order for exporting

$
0
0

Hi everyone!

 

I'm trying to do something but I can't achieve it. As you can see in the image I have a composition with parented layers. I'm working on a exporter that converts the data from AE to json but to do it properly I need to export those layer in the correct order that would be (looking to the index) 13,12,11,10,6,5,2,1,9,8,7,4,3 in an array.

 

This index should be gotten this way: I choose the layer named MAIN and then the script should read if it has got a child, if yes it keeps the index, it would go to the next layer and the same, it would look if it has a child, etc etc.

 

Could someone help me with this please? I have tried some different things but am unable to achieve it

 

Thanks!!

Scrollable panel gets truncated

$
0
0

I am trying to add a scrollbar to one of my panels (something I have tried for many years unsuccessfully).

 

I stumbled across Peter Kahrel's ScriptUI documentation and he has the following working code

var w = new Window('dialog');
w.maximumSize.height = 300;
var panel = w.add ('panel {alignChildren: "left"}');
var scrollGroup = panel.add ('group {orientation: "column"}');
for (var i = 0; i <= 35; i++) {
scrollGroup.add ('statictext', undefined, 'Label ' + i);
}
var scrollBar = panel.add ('scrollbar {stepdelta: 20}');
// Move the whole scroll group up or down
scrollBar.onChanging = function () {
scrollGroup.location.y = -1 * this.value;
}
w.onShow = function() {
// Set various sizes and locations when the window is drawn
panel.size.height = w.size.height-20;
scrollBar.size.height = w.size.height-40;
scrollBar.size.width = 20;
scrollBar.location = [panel.size.width-30, 8];
scrollBar.maxvalue = scrollGroup.size.height - panel.size.height + 15;
};
w.show();

 

my problem is, if I add more rows by changing line 05 to this

     for (var i = 0; i <= 300; i++) {

 

when I scroll the panel it gets to around 35 elements and then there is just blank area in the panel beyond that row.

 

Anybody good with this stuff, it is something I have needed to do for a long time but adobe's documentation really sucks.

After Effects CC 2017 (14.0) New Scripting Functionality

$
0
0

After Effects CC 2017 (14.0) includes new scripting access to tools, composition markers, the Queue In AME command, and GPU acceleration options.

 

The documentation and sample code below explains how to use this new functionality. We plan to post this to our blog, later in November as a part of series of in-depth articles about the new features in After Effects CC 2017, but we heard enough interest today that we thought you might appreciate seeing this sooner.

 

(Please pardon any formatting errors that may have occurred when pasting the sample code into this forum. I did my best to clean it up.)

 


Scripting Access to Tools


You can now get and set the active tool in the Tools panel using the new app.project.toolType attribute. This read/write attribute returns or accepts an enumerated ToolType value, of one of the following:

 

ValueTool Name
ToolType.Tool_Arrow

Selection Tool

ToolType.Tool_Rotate

Rotation Tool

ToolType.Tool_CameraMaya

Unified Camera Tool

ToolType.Tool_CameraOrbit

Orbit Camera Tool

ToolType.Tool_CameraTrackXY

Track XY Camera Tool

ToolType.Tool_CameraTrackZ

Track Z Camera Tool

ToolType.Tool_Paintbrush

Brush Tool

ToolType.Tool_CloneStamp

Clone Stamp Tool

ToolType.Tool_Eraser

Eraser Tool

ToolType.Tool_Hand

Hand Tool

ToolType.Tool_Magnify

Zoom Tool

GToolType.Tool_PanBehind

Pan Behind (Anchor Point) Tool

ToolType.Tool_Rect

Rectangle Tool

ToolType.Tool_RoundedRect

Rounded Rectangle Tool

ToolType.Tool_Oval

Ellipse Tool

ToolType.Tool_Polygon

Polygon Tool

ToolType.Tool_Star

Star Tool

ToolType.Tool_TextH

Horizontal Type Tool

ToolType.Tool_TextV

Vertical Type Tool

ToolType.Tool_Pen

Pen Tool

ToolType.Tool_Feather

Mask Feather Tool

ToolType.Tool_PenPlus

Add Vertex Tool

ToolType.Tool_PenMinus

Delete Vertex Tool

ToolType.Tool_PenConvert

Convert Vertex Tool

ToolType.Tool_Pin

Puppet Pin Tool

ToolType.Tool_PinStarch

Puppet Starch Tool

ToolType.Tool_PinDepth

Puppet Overlap Tool

ToolType.Tool_Quickselect

Roto Brush Tool

ToolType.Tool_Hairbrush

Refine Edge Tool

 

The following sample code checks the current tool, and if it is not the Unified Camera Tool, sets the current tool to that:

// Check the current tool, then set it to Unified Camera Tool (UCT).
{
    // Assume a composition is selected in the project.
    varcomp = app.project.activeItem;
    if (comp instanceof CompItem) {
        // Add a camera to the current comp. (Requirement for UCT.)
        varcameraLayer = comp.layers.addCamera("Test Camera", [comp.width/2, comp.height/2]);
        comp.openInViewer();

        // If the currently selected tool is not one of the camera tools, set it to UCT.
        if (( app.project.toolType != ToolType.Tool_CameraMaya) &&
            ( app.project.toolType != ToolType.Tool_CameraOrbit ) &&
            ( app.project.toolType != ToolType.Tool_CameraTrackXY) &&
            ( app.project.toolType != ToolType.Tool_CameraTrackZ))
                app.project.toolType = ToolType.Tool_CameraMaya;
    }
}

 

The following sample code uses the new app.project.toolType attribute to create a 360° composition (environment layer and camera) from a selected footage item or composition selected in the Project panel. This script a good starting point for building VR compositions from equirectangular footage:

// Create a 360 VR comp from a footage item or comp selected in the Project panel.

var
item = app.project.activeItem;

if
(item != null&& (item.typeName == "Footage" || item.typeName == "Composition")) {

    // Create a comp with the footage.
    varcomp = app.project.items.addComp(item.name, item.width, item.height, item.pixelAspect, item.duration, item.frameRate);
    varlayers = comp.layers;
    varfootageLayer = layers.add(item);

    //Apply the CC Environment effect and create a camera.
    vareffect = footageLayer.Effects.addProperty("CC Environment");
    varcamera = layers.addCamera("360 Camera", [item.width/2, item.height/2]);
    comp.openInViewer(); app.project.toolType = ToolType.Tool_CameraMaya;
}
else {
    alert("Select a single footage item or composition in the Project panel.");
}

 


Scripting Access to Composition Markers


Composition markers can now be created and modified via the new comp.markerProperty attribute. Composition marker scripting has the same functionality as layer markers.

 

The following sample code creates a project and composition, then creates two composition markers with different properties:

// comp.markerProperty allows you add markers to a comp.
// It has the same functionality as layer.property("Marker")
{
    varcurrentProj = app.newProject();
    varcomp = currentProj.items.addComp("mycomp", 1920, 1080, 1.0, 5, 29.97);
    varsolidLayer = comp.layers.addSolid([1, 1, 1], "mylayer", 1920, 1080, 1.0);

    var
compMarker = new MarkerValue("This is a comp marker!");
    compMarker.duration = 1; compMarker.url = "http://www.adobe.com/aftereffects";

    var
compMarker2 = new MarkerValue("Another comp marker!");
    compMarker2.duration = 1;

    comp.markerProperty.setValueAtTime(1, compMarker)
    comp.markerProperty.setValueAtTime(3, compMarker2)
}

 


Scripting Access to Queue in AME


The Queue In AME command, introduced in After Effects CC 2015.3 (13.8), can now be triggered via scripting. This requires Adobe Media Encoder CC 2017 (11.0) or later.

 

The new method app.project.renderQueue.queueInAME(render_immediately_in_AME) calls the Queue In AME command. This method requires passing a boolean value, telling AME whether to only queue the render items (false) or if AME should also start processing its queue (true).

 

Note that when AME receives the queued items, it applies the most recently used encoding preset. If render_immediately_in_AME is set to true, you will not have an opportunity to change the encoding settings.

 

The new read-only boolean attribute app.project.renderQueue.canQueueInAME indicates whether or not there are queued render items in the After Effects render queue. Only queued items can be added to the AME queue.

 

The following sample code checks to see if there are queued items in the render queue, and if so queues them in AME but does not immediately start rendering:

// Scripting support for Queue in AME.
// Requires Adobe Media Encoder 11.0.
{
    if (app.project.renderQueue.canQueueInAME == true)
    {
        // Send queued items to AME, but do not start rendering.
        app.project.renderQueue.queueInAME(false);
    }
    else {
        alert("There are no queued item in the Render Queue.");
    }
}

 


Scripting Access to Available GPU Acceleration Options


You can now use scripting to request which GPU acceleration types are available on the current computer. The new read-only attribute app.availableGPUAccelTypes returns an array of gpuAccelType enums.

 

Use this in conjunction with app.project.gpuAccelType to set the value for Project Settings > Video Rendering and Effects > Use.

The following sample code checks the current computer's available GPU acceleration types, and sets it to Metal if available:

// app.availableGPUAccelTypes returns GPU acceleration types available on the current system.
// You can use this to check before setting the GPU acceleration type.
{
    varnewType = GpuAccelType.METAL;

    // Before trying to set, check which GPU acceleration types are available on the current system.
    varcanSet = false;
    varcurrentOptions = app.availableGPUAccelTypes;
    for (op in currentOptions) {
        if (currentOptions[op] == newType)
            canSet = true;
    }

    if
(canSet) {
       // Set the GPU acceleration type.
        app.project.gpuAccelType = newType
    }
    else {
        alert("Metal is not available on this OS.");
    }
}

Remember whether a checkbox was checked or not in a dockable UI panel, after restarting AE?

$
0
0

Hi there,

 

I have a dockable UI panel, where the user can hide or show various buttons by checking and unchecking checkboxes. After restarting After Effects I want the same checkboxes checked, as the user defined before the restart. How can I achieve this when the distribution file will be one .jsxbin file?

 

Does anyone have any idea?

Thanks!

Extendscript for AE. Reference comp by NAME, not by index.

$
0
0

Hi everyone, first time poster.

 

I'm making my own plugins for AE for my own toolkits.

 

I have a main composition called MAIN_CONTROL. What i want to do is reference this by the name and not index. I want to see if this comp contains a layer, and run a function based on whether or not it does. So....

 

var chkLayer = app.project.MAIN_CONTROL.layer("Layer Name");

if (chkLayer == undefined){

//do this

}else{

//do that

}

 

As of now i can access it by "index" using app.project.item(1).layer("Layer Name")......

But as i build my project and if i re-organize that MAIN CONTROL comp into a subfolder, the index changes and everything breaks.

For some reason this seems so basic, but it is a pain in the butt.

 

Any help is appreciated.

Text animation Approach

$
0
0

How to modify, by script, the approach value of the text animation

Thanks

Open local folder

$
0
0

Hiiiiiii!!!!

 

I can´t find any information about this. Does anyone know how to open a local folder using javascript inside after effects?

 

There something about "window.open("file:///"  " but doesn't work. Any clue??

 

Thanks!!!


How can I change an image in After Effect Design using a Node.js expression?

$
0
0

The project aims to create a video dynamically using node.js and php, starting from an adobe after effects project. All the texts and paths of the images in the video must be replaced dinamically using after effects scripts . The images must be taken and loaded from a project folder that will be dynamically populated, so the images cannot be imported in project at the beginning, but they have to be inserted after using after effect script.

 

How can i do this? What are the instruction to replace dinamically an image?

 

How to interact between an Extendscript and C++ plugin?

$
0
0

I have developed a plugin for after effects using C++, i have written the UI for the plugin using extendscript, how can i send and receive data from the extendscript to the plugin?

Extendscript - Adding a vector shape to a group.

$
0
0

I need help figuring out how to add the shape to a group. I need access to the group transforms so I can position each of the paths I am creating.

 

Here is an image of what I would like to achieve.

https://drive.google.com/file/d/1OEzRtp1ILlZR7L5T_7BPfk-JlYiaQRPg/view?usp=...

 

 

What I have so far only creates a shape layer with a vector path without a group.

var sVerts= [[-4.66796875,-4.614013671875],[-4.66796875,-1.584716796875],[4.701171875,-1.584716796875 ],[8.44921875,1.823486328125],[8.44921875,3.798095703125],[4.701171875,7.206298828125],[-4 .66796875,7.206298828125],[-8.44921875,3.798095703125],[-8.44921875,3.387939453125],[-5.31 25,2.809814453125],[-5.3125,4.512939453125],[5.283203125,4.512939453125],[5.283203125,1.20 8251953125],[-4.048828125,1.208251953125],[-7.833984375,-2.199462890625],[-7.833984375,-3. 797607421875],[-4.048828125,-7.206298828125],[4.498046875,-7.206298828125],[8.283203125,-4 .072998046875],[8.283203125,-3.729248046875],[5.248046875,-3.082275390625],[5.248046875,-4 .614013671875]]; var sITans= [[0,0],[0,0],[0,0],[0,-2.7265625],[0,0],[2.86328125,0],[0,0],[0,2.693359375],[0,0],[0,0], [0,0],[0,0],[0,0],[0,0],[0,2.728515625],[0,0],[-2.83203125,0],[0,0],[0,-2.51806640625],[0, 0],[0,0],[0,0]]; var sOTans = [[0,0],[0,0],[0,0],[0,-2.7265625],[0,0],[2.86328125,0],[0,0],[0,2.693359375],[0,0],[0,0], [0,0],[0,0],[0,0],[0,0],[0,2.728515625],[0,0],[-2.83203125,0],[0,0],[0,-2.51806640625],[0, 0],[0,0],[0,0]]; logoShapeLayer = activeItem.layers.addShape(); logoShapeLayer.name="S Path"; sShapeGroup = logoShapeLayer.property("ADBE Root Vectors Group"); sShapeGroup.addProperty("ADBE Vector Shape - Group"); logoShapeGroup.addProperty("ADBE Vector Graphic - Fill"); var sShape = new Shape(); sShape.vertices = sVerts; sShape.inTangents = sITans; sShape.outTangents = sOTans; sShape.closed = true; sShapeGroup.property(1).property("ADBE Vector Shape").setValue(sShape);

Extendscript Toolkit freezes intermittently when linked to AE CS 2014

$
0
0

Whenever I have ESTK linked to AE CC 2014 I get intermittent freezes, during which ESTK becomes unresponsive for a few seconds.  Unlinking it from AE eliminates these freezes, but this obviously means I can't use the data browser.

 

I don't get these sorts of freezes when linked to Photoshop CC 2014, which would imply that this is a problem with After Effects.  Has anyone else encountered this problem, or does anyone have any suggestions for how to solve it?

 

I get this behavior on both my nearly brand new MacBook Pro with 16 GB RAM running Yosemite and on a Mac Pro 5,1 with 48 GB RAM running Mavericks, both with AE 13.1.1.3 and ESTK 4.0.0.1.

Download image with extend script

$
0
0

Hi.

this is my codes for download image with extend script on after effects.

what is the problem?

my image created but it size is 0 kb.

What should be in line 17 for the server?

thanks all.

webConnect = new Socket;
 if(webConnect.open( "creative.magnetadservices.com:80")) {        webConnect.write('GET /2017/12/279ecb7175794506885fd7fd23cfe29b/NativeAdLandscapeImage-small.jpg HTTP/1.0\n\n');     var file= new File("httpSocket.jpeg");     file.encoding='BINARY'     file.open ("w");
var contentLength = ""
var statusCode = ""
for (var i = 0; i < 20; i++){     var response =  webConnect.readln();     if (new RegExp(/HTTP\/[0-9.]+\s([0-9]+)/).test(response)){          statusCode = parseInt( new RegExp(/HTTP\/[0-9.]+\s([0-9]+)/).exec(response)[1]);     }     else if (new RegExp(/Content-Length: ([0-9]+)/).test(response) ){          contentLength = parseInt( new RegExp(/Content-Length: ([0-9]+)/).exec(response)[1]);     }     else if (new RegExp(/Server: AmazonS3/).test(response) ) {  break;     }
}

if (statusCode != 200) webConnect.close()
else{
alert('statusCode=' + statusCode + ' contentLength=' + contentLength);
    var data = webConnect.read(contentLength);
alert(data.length);     file.write(data);
}     file.close();     file.execute();
}

UI Panel submenu

$
0
0

Hello everyone,

I'm actually struggling with UI Panel on extendscript.

I managed to build a panel with multiple buttons, but not responsive or sizeable but i have a bigger problem, I want to "clean" my panel and create another with new icons when a button is clicked.

I tried the remove method, the visible parameter, everything, i don't see how it is doable.

I paste the code here so you'll better understand.

 

Thanks a lot

 

var dir = "(images)/";
var icons = {a: File(dir+"a.png"), b: File(dir+"b.png"),
c: File(dir+"c.png"), d: File(dir+"d.png")}



function createUI(thisObj) {
    var win = (thisObj instanceof Panel) ? thisObj : new Window("palette", "My Window", undefined);    win.orientation = "row";
 var myPanel = win.add("panel", [5,5,300,450]);
 myPanel.orientation = "row";    var aButton=myPanel.add("iconbutton",[undefined,undefined,120,120],icons.a);    don.location = [10, 10];    var bButton=myPanel.add("iconbutton",[undefined,undefined,120,120], icons.b);    line.location = [160, 10];    var cButton=myPanel.add("iconbutton",[undefined,undefined,120,120], icons.c);    rad.location = [10, 160];    var dButton = myPanel.add("iconbutton",[undefined,undefined,120,120], icons.d);    hist.location = [160, 160];   

aButton.onClick = function(){ aFunction()};
bButton.onClick = function(){bFunction()};
cButton.onClick = function(){cFunction()};
dButton.onClick = function(){dFunction()};

return win;
}

How to render to a stream (allow web users to stream rendering video)

$
0
0

I am using Adobe After Effects CC and ExtendScript to create dynamic videos and then let the user watch those videos.

 

I looked at this tutorial (don't need to read this tutorial to understand the context of this discussion): https://www.themarketingtechnologist.co/creating-dynamic-videos-using-javascript-and-after -effects-the-basics/

 

Basically, the tutorial goes through how to create dynamic videos with After Effects and render them.

 

Right now, I can use extend script to create dynamic videos to the user's preferences and render them.

 

However, when I render the video, I have to wait till rendering is completely done before the user can start watching the video at 0:00 (via a HTML5 player).

 

Is there a way to allow the user to stream the video as soon as the first frame or block of frames is rendered?

 

In other words, is there a way to allow the user to stream a video before that video has fully rendered.


Should I directly render the video on After Effects or Adobe Media Encoder?

 

Thank you!


After-Effects renders videos too big of a filesize; how to reduce filesize?

$
0
0

Problem: I render After Effects Video and get a file size too big - 4GB!
Broken Solution: Use Adobe Media Encoder, but it is not supported by ExtendScript - 160MB (25 times smaller).


More information below:

ExtendScript

var rq_item =app.project.renderQueue.items.add(comp); // add the comp to the render queue

rq_item.outputModule(1).file=File('~/Desktop/out.mov'); // set the output path

rq_item.render=true; // set it to enabled (is the default)

app.project.renderQueue.render();

 

However, the size of the 1080p rendered video is about 4GB. It is just a very simple 2 minute video.

 

I had this problem with After Effects before. To solve it, I was told to use Adobe Media Encoder. This solved my problem. For some reason, using Adobe Media Encoder to render the After Effects file drastically reduces the file size to 160MB. A lot of online forums say "Use Adobe Media Encoder" as a solution to the large file size problem.

 

I heard from other posts (no official posts) that ExtendScript does not officially support Adobe Media Encoder.

 

How do I modify the above ExtendScript to make it as effective as me using the Adobe Media Encoder to render the video to have filesize 160MB instead of 4000MB?


Any workarounds? Or maybe a way to automate the use of Adobe Media Encoder via commandline?

 

 

Thank you!

JSON throw syntax error

$
0
0

I've been scratching my head for the last couple of hours trying to get a JSON object into my script.

 

I've been following this tutorial and several others and I've got the code below:

 

// Testing data get
#include "~/Desktop/test/json2.js"    var myFile = new File ("~/Desktop/test/testData.json");    if (myFile.open("r")){            myFile.encoding = "UTF-8";            var myJson = myFile.read();            var myObject = JSON.parse(myJson);            myFile.close();            }        myObject.email;

 

 

However, every time I run this it opens up a new javascript file (starting with ADOBE CONFIDENTIAL) highlighting 'throw SyntaxError()' on line 1364.

 

// Internal: Resets the parser state and throws a `SyntaxError`.        var abort = function () {          Index = Source = null;          throw SyntaxError();        };

 

I'm testing using AE 2017.2 and ExtendScript V4. If anyone could point me in the right direction that would be great.

 

EDIT: Instead of using '#include', I also tried minifying and including the json2 code but still no luck.

get keyframe bezier handles magnitude values?

$
0
0

So we can get the handle's values like this:

 

alert( app.project.activeItem.selectedLayers[0].position.keyOutSpatialTangent(1) );

 

but how on earth can I get the magnitude, or something else that would help to describe the length of the bezier handle?

capture.png

Remove empty folders and Subfolders

$
0
0

Hello i'm trying to clean my project .i have a lot of empty folder and folder with subfolder inside ....

 

Sometimes,i have many level off subfolders empty inside one and i try to delete them.

 

i try this code, its work for simple folder, but i still have folder with subfolder inside and i cant delete this kind of files ....

 

any idee ??

 

Thank you everyone...

 

 

 

//remove emty folders

 

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()}

hovertext for scriptui elements

$
0
0

Hey guys,

This is probably the simplest thing in the world - how do you add hovertext for your ScriptUI elements in Extendscript?

Viewing all 2143 articles
Browse latest View live


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