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

Updating a progressBar in a scriptUI panel

$
0
0

I have an After Effects script with a ProgressBar. If I run this script by clicking File >> Scripts >> Run Script File then the progress bar works fine. However, if I run this script by copying it to this folder:

 

C:\Program Files\Adobe\Adobe After Effects CC 2018\Support Files\Scripts\ScriptUI Panels

 

and then running it by clicking Window >> MyCoolScript then the line panel.update() crashes. The main difference between both ways of running the script is whether the main thing is a panel or a window, so I suppose this is related to the issue? The easy solution is to not panel.update(), but then the progress bar doesn't actually update visually while running the script.

 

So, my question is: how do I make a progress bar show its progress in a scriptUI panel?

 

Here's a simple script that shows the problem in action:

 

function doExport(panel)

{

     if (panel != undefined && panel != null)

     {

          panel.grp.exportProgressbar.value = 10;

          panel.grp.exportProgressbar.show();

          panel.update();

          panel.grp.exportButton.text = "banana";

     }

}

 

{

     function createPanel(thisObj)

     {

          function buildUI(thisObj)

          {

               var panel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "bla", undefined, {resizeable:true});

               res = "group\

               {\

                    orientation:'row',\

                    exportButton: Button {text:'Export'},\

                    exportProgressbar: Progressbar {text:'busy'},\

               }";

               panel.grp = panel.add(res);

               panel.grp.exportProgressbar.maxValue = 100;

               panel.grp.exportProgressbar.hide();

               panel.grp.exportButton.onClick = function() { doExport(panel); }

               panel.layout.layout(true);

               return panel;

          }   

 

          var panel = buildUI(thisObj);

          if (panel != null && panel instanceof Window)

          {

               panel.center();

               panel.show();

          }

     }

     createPanel(this);

}


Controlling multiple effects via script error

$
0
0

Hey

 

I can add a single effect and update it fine, but I keep getting an “object is invalid” error, any time I add a second effect to a layer, then try to change a value of one of the properties of the first effect… The only way I've got it to work is by updating the slider and coord variables before updating the expressions again.

 

Which I can do... but can't understand why I would need to do that.

 

var curComp = app.project.activeItem;
var curLay = curComp.selectedLayers[0]; 

var slider = curLay.Effects.addProperty("ADBE Slider Control");  
slider.property("ADBE Slider Control-0001").expression = "1234"; // works

var coords = curLay.Effects.addProperty("ADBE Point3D Control"); 
coords.property("ADBE Point3D Control-0001").expression = "[10,10,10]"; // works

//slider = curLay.effect.property("ADBE Slider Control");
slider.property("ADBE Slider Control-0001").expression = "5678"; // works with line above uncommented

//coord = curLay.effect.property("ADBE Point3D Control");
coord.property("ADBE Point3D Control-0001").expression = "[5,5,5]"; // works with line above uncommented

 

Is there a better way / any ideas?

 

Cheers

 

James

#include onClick only ??? Is it possible?

$
0
0

Aloha, insane coders!

 

Anybody knows how #include works exactly?

 

 

I have a huge script, and it's taking too long to load.

I split my code into multiple slices, then call one by one with the #include function.

I'm trying to do the include function based on an onClick function.

But it seems like the #include still reading all my content even if the button is not clicked yet.

 

 

I don't know if I made myself clear.

Let try to explain the details.

I have a Dockable Panel, which my user can keep docked and always ready to use. But even if my user will not effectively need to use "my script" on that session, "my script" is loading all elements.

 

 

I wonder if that is a way to use eval() or some other option, to only read the content of include when the user requires.

By doing this, I will save time, memory and processing from the end user.

 

 

Here's one example of my code.

Can anybody help me to find a solution only to read the content if the button was clicked? 

 

 

Thanks!

 

 

Rubens Nobre

 

 

 

 

var thisObj = this;
var myWindow;  


//check if this Obj is a panel (run from Window menu)  
if(thisObj instanceof Panel) {       //is a panel (called from Window menu)       myWindow = thisObj;      } else{       //not a panel (called from File > Scripts > Run)       alert("INCORRECT INSTALL, Please check installation manual");      }  


var group01 =  myWindow.add("group", undefined, "mainGroup", {borderless: true});
var btn01 = group01.add("button", undefined, "button 01");


myWindow.alignment = "center","center";     
myWindow.layout.layout(true);
myWindow.onResize = function(){myWindow.layout.resize (); }  




btn01.onClick = function(){ 
    alert("Only include the file if btn is clicked");    #include "MyLongScript.jsx"     }

Que comp in AME, run script when done

$
0
0

Hi guys,

 

I'm working on our studio's pipeline and would like to script some of our AE rendering tasks. At the moment, this step is too manual which obviously creates issues working with a larger team. What I would like to do:

 

- Output directory and file name are automatically set by the script via the project management system. This works fine.

- I would like to render the comp to a h264 preset using the AME. I have found how to add the comp to AME and start the render:

app.project.renderQueue.queueInAME(true)

 

I just can't find any options in the documentation, just this single command. I need to do the following:

 

- Set the output directory and filename

- Run a script when the render is done (need to copy the file to some places and use ffmpeg to convert to different formats)

 

I really just need the script to run after rendering since this could copy/rename the file as well of course.

 

Any help is appreciated, thanks in advance!


Vincent

How to setValue of a property that isn't selectable for GimmePropPath (Colorama > Use Preset Palette)?

$
0
0

Hi guys, I'm very new to scripting but love After Effects, I'm finding a lot of useful information online though admittedly PropertySpec seems pretty ambiguous and I've been having trouble. I'm trying to create a new comp, add a solid the size of that comp, then stack a few effects with one or two values needing changed as an exercise (instead of something like a preset for this). So I create a solid with Gradient Ramp and Colorama:

 

var myComp = app.project.activeItem;

 

if (myComp != null){

    var w = myComp.width;

    var h = myComp.height;

    var mySolid = myComp.layers.addSolid([1, 1, 1], "Displacement Map", w, h, 1.0);

    var firstLayer = myComp.layer(1)

    var addRamp = firstLayer.Effects.addProperty("Gradient Ramp");

    var addColorama = firstLayer.Effects.addProperty("Colorama");

    var fxRepetitions = firstLayer("Effects")("Colorama")("Cycle Repetitions");

    var fxPreset = firstLayer("Effects")("Colorama")("Use Preset Palette");

    fxRepetitions.setValue(5)

    alert(fxPreset);

//~          reports [Object property]

    fxPreset.setValue("Solarize Grey")

//~           error "Unable to call setValue because of parameter 1. Solarize Grey is not a number"

}else{

    myComp = app.project.items.addComp("New Comp", 960, 540, 1.0, 10.0, 25);

}

 

My alert shows [Object property] for "Use Preset Palette", but I don't know how to assign Solarize Grey to it. How would I change this so Colorama results in greyscale instead of coming out like a rainbow here, if not for Preset Palette and GimmePropPath? How do I retrieve that kind of information?

 

Also, is there no syntax for code in this forum editor?

Add Expression on Selected Property Items

$
0
0

Hello,

 

since I am very new to this field, I apologize if the answer is obvious or has already been discussed (unfortunately I could not find anything yet...)

 

Below is one of my first scriplets:

this is a simple script that creates the wiggle expression + 2 slider controller on the position

 

var myComp = app.project.activeItem;

myLayer = myComp.layer(1);

 

var mySlider1 = myLayer.property("Effects").addProperty("ADBE Slider Control");

mySlider1.name = "Time";

 

var mySlider2 = myLayer.property("Effects").addProperty("ADBE Slider Control");

mySlider2.name = "Value";

 

var expWiggle = "wiggle(effect(1)(1), effect(2)(1))";

myLayer.position.expression = expWiggle;

 

My question:

How can I modify the script so that the expression is automatically applied to whatever property is SELECTED?

Say when rotation is selected, it is set to rotation; when scale is selected, it is set to scale;....

 

Many thanks for your help

 

all the best

B

Merging multiple radio button groups for one possible result

$
0
0

Hey.

 

I have 3 groups each with two radio buttons in. I want only one button to checked at a time, but unfortunately you can still check one button from each group.

From looking online, I've read that they all need to have the same name in order to be part of the same 'radio group'. But no matter where I've put a

.name = "sameGroup"

it hasn't worked.

 

Is this possible? Or do I need to create an eventListener for each button, which unchecks all other buttons upon being clicked.

 

Here is an example of my code below:

 

var w = new Window("dialog", "test", undefined, {}); // create window
// create main group
var radGrpMain = w.add('Group', undefined);
radGrpMain.alignChildren = ['left', ' '];
radGrpMain.orientation = 'row';


// create left sub group
var radGrpL = radGrpMain.add('Group', undefined);
radGrpL.orientation = 'column';
// create mid sub group
var radGrpM = radGrpMain.add('Group', undefined);
radGrpM.orientation = 'column';
// create right sub group
var radGrpR = radGrpMain.add('Group', undefined);
radGrpR.orientation = 'column';

// add buttons
var rad1 = radGrpL.add("RadioButton", undefined, "Radio 1");
rad1.value = true; // default true.
rad1.name = "sameGroup";
var rad2 = radGrpL.add("RadioButton", undefined, "Radio 2");
rad2.name = "sameGroup";
var rad3 = radGrpM.add("RadioButton", undefined, "Radio 3");
rad3.name = "sameGroup";
var rad4 = radGrpM.add("RadioButton", undefined, "Radio 4");
rad4.name = "sameGroup";
var rad5 = radGrpR.add("RadioButton", undefined, "Radio 5");
rad5.name = "sameGroup";
var rad6 = radGrpR.add("RadioButton", undefined, "Radio 6");
rad6.name = "sameGroup";

w.show(); // show window

 

 

Any help appreciated!

 

James

convert path text string to shape layer with extendscript

$
0
0

hey guys how do you take a svg string such as

 

M 321.100341796875 0 C 498.4391479492188 0 642.20068359375 135.6577301025391 642.20068359375 303 C 642.20068359375 470.34228515625 498.4391479492188 606 321.100341796875 606 C 143.7615203857422 606 0 470.34228515625 0 303 C 0 135.6577301025391 143.7615203857422 0 321.100341796875 0 Z

 

and turn it into data that can be used to make a shape layer?

i know i have to turn this into the point coordinates, inout tangents,  and check if its a closed path but I have no idea where to start. Any help would be much appreciated. thanks in advanced.


Socket timeout function???

$
0
0

Hello Insane coders.

 

Anybody knows if it's possible to set a timeout function into an HTTP connection using a socket?


Thanks.

 


Rubens Nobre

Extension doesn't load after.jsx script has been edited

$
0
0

Hi. I am new to extension dev. I have an extension working in AE. But I wanted to add some code to one of its .jsx files. I added the code. Then removed it.Saved the file. But from then on the extension doesn't load into AE. Why? Is there some sort of binary signature? Do I have to do some "build step?

Get Array of all Pixels in Composition

$
0
0

Is it possible to obtain an array that contains all of the pixels in the active document's current composition at a given frame?  By "array of pixels," I'm referring to an array that contains all of the color data associated with each pixel in the composition.  By composition, I'm referring to whatever is currently visible in the composition view (with all effects applied to layers, all layer blending modes considered, etc.)  For example, if my composition currently looks like this:

 

download.png

 

Then the pixels in my array should correspond to black, blue, and white pixels.  The exact representation of the pixel is unimportant; whether RGB, Hex, integer, etc, anything is fine as long as it contains some kind of interpretable color data.  The ordering in the array is also unimportant for my specific application.  Can this be done inside an after effects script, and if so, how?

"Null is not an object" error in After Effects Script

$
0
0

I am trying to write a script that changes the color of an object to a different color (In this instance I am changing all blue solids to red solids). The script works just fine until I include an object in the timeline of a comp that is not defined in the library. For example if I use the rectangle tool to draw a square it creates an object in the timeline that does not appear in the library. Does anyone know how I could tell AE to ignore these objects when it comes across them instead of giving me the "Null is not an object" error and stopping the script from finishing? I'm very new to scripting so any advice is welcomed.

 

Here is the script I am using:

 

 

try{

    //----------------------------------Variables----------------------------------

    var proj = app.project;

    var itemTotal = proj.numItems;

    var solidColor = [1, 0, 0];

    var curItem, curComp, totalComps, totalLayers, curLayer, curLayerIndex, curLayerSource;

    var itemAry = new Array();

 

    //----------------------------------Loop through project items----------------------------------

    app.beginUndoGroup("Blue to Red");

    for(var i = 1; i <= itemTotal; i++){

        //item assignment

        curItem = proj.item(i);

        //Check if item is comp

        if(curItem instanceof CompItem){

            itemAry[itemAry.length] = curItem;

            }

        }

   

        totalComps = itemAry.length;

  

    for(var c = 0; c < totalComps; c++){

//--------------------------------------------------------------

 

            //----------------------------------Variable assignment----------------------------------

            curComp = itemAry[c];

            totalLayers = curComp.numLayers;

           

            //Loop through layers

            for(var l=1; l<=totalLayers; l++){

                curLayer = curComp.layer(l);

                curLayerIndex = curLayer.index;

                curLayerSource = curLayer.source.mainSource;

               

              

            //------Check layer, if it is a solid and it's blue, change it to red (Change this to set new color)———

            if(curLayerSource instanceof SolidSource && curLayerSource.color == "0,0,1"){

                curLayerSource.color = [1,0,0];

                }

           

                //Update info panel with progress

                writeLn("Layer " + curLayerIndex.toString() + " updated");

                }

//------------------------------------------------------------------          

        }

    app.endUndoGroup();

 

    alert("All Done.");

   

//If an error occurs, catch it and show me

}catch(err){

    alert("Error at line # " + err.line.toString() + "\r" + err.toString());

   

}

Drawing mask with OutTangents and InTangents

$
0
0

Hi, I faced a problem when I want to draw a shape from mask. I tried to draw one side of shape on solid layer and then convert it to mask and exclude InTangents, OutTangents, and to mirror other side in script. But I can't get proper image. I will add code and 2 pictures.
1 picture(what shape I get)

2 picture(how it should look)

var myShape = myComp.layers.addShape(); 
myShape.name = ("Batman");

myShape.property("Transform").property("Position").setValue([0,0,0]); 
var myShapeContent = myShape.property("Contents").addProperty("ADBE Vector Group");
var myShapeGroup = myShape.property("Contents").property("Group 1"); 
var myShapePath = myShapeGroup.property("Contents").addProperty("ADBE Vector Shape - Group");
var myShapeMask = myShapePath.property("Path");
var myShapeMask2 = myShapeMask.value; 
var compEffect3 = myComp.layer("Batman").Effects.addProperty("Glow"); 
var compEffect3 = myComp.layer("Batman").Effects.addProperty("ADBE Fast Blur"); 
myShape.property("Effects").property("ADBE Fast Blur").property("Blurriness").setValue([600]);
var p1 = [w2-0, h2+360];
var p2 = [w2-354, h2+44];
var p3 = [w2-529, h2+95];
var p4 = [w2-653, h2-25];
var p5 = [w2-901, h2+127];
var p6 = [w2-699, h2-190];
var p7 = [w2-410, h2-361];
var p8 = [w2-371, h2-254];
var p9 = [w2-89, h2-189];
var p10 = [w2-62, h2-304];
var p11 = [w2-26, h2-231];
var p12 = [w2-0, h2-226];
    var p13 = [w2+25, h2-231];    var p14 = [w2+61, h2-304];    var p15 = [w2+88, h2-189];    var p16 = [w2+370,h2-254];    var p17 = [w2+409, h2-361];    var p18 = [w2+698, h2-190];    var p19 = [w2+900, h2+127];    var p20 = [w2+652, h2-25];    var p21 = [w2+528, h2+95];    var p22 = [w2+353, h2+44];    var p23 = [w2-0, h2+360];  //InTangents, outTangents
//One side  var in1 = [4.209228515625,-1.51101684570312];  var out1 = [-234,84.0000610351562];  var in2 = [-1.416259765625,1.4122314453125];  var out2 = [178.499847412109,-178.000061035156];  var in3 = [-4.1431884765625,1.68316650390625];  var out3 = [256,-104];  var in4 = [0,0];  var out4 = [0,0];  var in5 = [0,0];  var out5 = [0,0];  var in6 = [0,0];  var out6 = [0,0];  var in7 = [0,0];  var out7 = [0,0];  var in8 = [0,0];  var out8 = [0,0];  var in9 = [0,0];  var out9 = [0,0];  //Other side  var in1 = [-4.209228515625,1.51101684570312];  var out1 = [234,-84.0000610351562];  var in2 = [1.416259765625,-1.4122314453125];  var out2 = [-178.499847412109,+178.000061035156];  var in3 = [4.1431884765625,-1.68316650390625];  var out3 = [-256,104];  var in4 = [0,0];  var out4 = [0,0];  var in5 = [0,0];  var out5 = [0,0];  var in6 = [0,0];  var out6 = [0,0];  var in7 = [0,0];  var out7 = [0,0];  var in8 = [0,0];  var out8 = [0,0];  var in9 = [0,0];  var out9 = [0,0];






myShapeMask2.vertices = [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23];
myShapeMask2.inTangents = [in1,in2,in3,in4,in5,in6,in7,in8,in9,in10,in11,in12,in13,in14,in15,in16,in17,in18];
    myShapeMask2.outTangents = [out1,out2,out3,out4,out5,out6,out7,out8,out9,out10,out11,out12,out13,out14,out15,out16,out17,out18];    myShapeMask2.closed = true;    myShapeMask.setValue(myShapeMask2);

 

ooo.png

 

batman.png

Save text from type layer in file using an expression

$
0
0

What I would like to do is save the type in a text layer to a file using an expression. I know I can do this with a script, but I need a more on-demand solution. This is a comp that is being used in Premiere via dynamic link and I would like to make a record of the text input from Premiere to AE. I see there is a way to run JSX using eval from an expression via https://forums.adobe.com/thread/2284729 like this:

 

     sPath = '/c/Users/Username/Desktop/yourscript.jsx' 

     readXml = $.evalFile( sPath ); 

 

 

but I don't see a way to pass any variables to the script. Boo. Is there a way to do this?

 

A little more info: Why am I trying to do this? My setup is that I have some animated text in a Cinema 4D comp. This comp is loaded into AE via Cineware. I'd like the type in Cinema 4D to be live type, as I am creating a toolkit for use by several Premiere editors and need the ability to dynamically change the text based on user input. I've tried a lot of ways to do this such as trying to use some unused value in the comp camera, but AE does not send any likely targets, like Focus Distance, to C4D, so I can't use that as a way to sent of text data. My current plan is to try and save an intermediary file and load it with Python in C4d, thus the question above.

 

All help appreciated!

JSON and thisComp.layer(index).name

$
0
0

Hello, I am attempting to extract data from a JSON file while using the name of the layer.

 

This is my JSON file called exportedxls.json

[{"p1":"0.1"}]

 

The below code will return the value 0.1:

eval("var variable="+footage("exportedxls.json").sourceText);

hauteur = variable[0].p1;

 

However, I would like the "p1" to come from the layer's name so I replaced it by "thisComp.layer(index).name"

 

I tried the below code but it will not return any value:

eval("var variable="+footage("exportedxls.json").sourceText);

hauteur = variable[0].thisComp.layer(index).name;

 

Note that the layer's name is p1.

 

Any idea what I am doing wrong?

 

Thank you!


Working with AE Preference settings

$
0
0

Hi everybody,

 

I have a checkbox defined as this:

 

var passThrough = groupTwo.add ("checkbox", undefined, "passThrough");

 

And I'm trying to store the checkbox value in the AE Preference setting file, using this code here:

 

passThrough.onClick = function(){          app.settings.saveSetting("EVLCopy", "passThrough", passThrough.value);        }

 

It doesn't work.

The getSetting method doesn't work neither (over a setting that already exists in the file):

 

passThrough.onClick = function(){          var testing = app.settings.getSetting("AE_OpenGL","Downsample Factor");          alert(testing);        }

 

What the heck am I doing wrong?

Error including .jsxbin

$
0
0

Hello Insane coders.

 

 

I'm about to finalize a huge script.

But I got a weird behavior.

 

If I include the .jsx files. Everything works fine.

But if I convert this same file to .jsxbin and include,

My script crashes, showing that error:

 

( Unable to execute the script at line 1. expected: ; )

 

 

Does anybody know why this is happening?

 

 

Thanks, Rubens Nobre.

Call After Effects JSX (ExtendScript) from Python

$
0
0

Hello,

 

I was wondering if it was possible to call a After Effects ExtendScript from Python?

 

I was wondering if there was a library/wrapper available?

 

Thanks!

Using Script to turn a mask on or off in After Effects

$
0
0

I am looking for a way to turn the mask on this blue solid from “Add” to “None” using script. The closest script I could find that does this is here:

 

var myComp = app.project.activeItem;

var greenSolid = myComp.layers.addSolid([0,1.0,0], "Green Solid", 50, 50, 1);

var newMask = greenSolid.Masks.addProperty("Mask");

var myMaskShape = newMask.property("maskShape");

var myShape = myMaskShape.value;

myShape.vertices = [[10,10],[10,40],[40,40],[40,10]];

myShape.closed = true;

newMask.maskMode = MaskMode.NONE; // note the lower case "m" in ".maskMode"

newMask.maskExpansion.setValue(7.5);

myMaskShape.setValue(myShape);

 

This script creates a green square and then puts a mask around it that you can change the property of in the line “newMask.maskMode = MaskMode.NONE;”

 

I just need to be able to refer to the mask on the solid instead of create it like in the script above. Does anyone know how I would write that out?

Screen Shot 2018-05-21 at 1.53.48 PM.png

Automatic color change for specific words

$
0
0

Hello

 

I have a .jsx project with an automatic text change from a .csv but the texte is supposed to have words with different colors.

I succeded to change the text color automaticly but I want to change some specific words.

For example if the text layer contains : "where is my umbrella" I want "where is my" in white and "umbrella" in red.

 

Do you think we can do this color changement for some words automaticly ? If we could do it directly in After Effects, it should be possible by scripting, isn't it ?

 

I thought about two ways of doing it but I'm stuck.

 

- On the csv file, I put the word I want in red in bold. Then in my after effects script I say something like "if you see bold texte, then it's red". But I couldn't modify a piece of the text layer, only the entire layer.

 

- On the csv file I write on another column "Umbrella" and I say on my script "If in the text into this column contains the same words than the layer text (which had been changed before), then put this words in red ". But I had the same problem, how to select a specific word into a after effects text layer into my script ? The documentation don't say a word about this.

 

Do you think it is even possible ? Am I on the good path ? If you have another solution, I'm listening!

 

Thank you very much.

Viewing all 2143 articles
Browse latest View live


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