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

Open Windows folder via scriptUI button

$
0
0

Hello,

I am very inexperienced when it comes to scripting.

I've attempted to make an After Effects interface containing a button that when clicked opens a folder that has been created by the script. The command to open the folder works fine, but when I put it in the button function nothing happens. What am I doing wrong? I'm using a Windows workstation.

 

Here are the essentials of the code:

 

app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);

app.newProject();

main();

function main(){

    var proj = app.project;

    var filePath = "C:\\ScriptUI\\TEST\\subDir\\";

   

    while(Folder(filePath).exists == false){ 

        Folder(filePath).create(); 

        }

   

    //system.callSystem("explorer " + filePath);        //this line works and is re-used in a button function on line 30 where it doesn't work

   

    //-------------------------INTERFACE------------------------------

   

    //window and panel creation

    var dlg = new Window("dialog", "");

    dlg.btnPnl = dlg.add("panel", undefined, "Render finished!");

   

    //buttons

    dlg.btnPnl.openBtn = dlg.btnPnl.add("button", undefined, "Open folder");

    dlg.btnPnl.closeBtn = dlg.btnPnl.add("button", undefined, "Close");

   

    //just giving the user a visual representation of the file path

    var msg = dlg.add("statictext");

    msg.text = filePath;

 

 

    //button functions

    dlg.btnPnl.openBtn.onclick = function(){

        system.callSystem("explorer " + filePath);      //same as line 12 but nothing happens this time

        }

   

    dlg.btnPnl.closeBtn.onClick = function(){

        dlg.close();

        proj.close(CloseOptions.DO_NOT_SAVE_CHANGES);

        }

 

 

    dlg.show();

 

    }

 

 

Any hints appreciated


How to emulate skew axis animation?

$
0
0

Hello,

 

I put an effect on the picture "ADBE Geometry2"

 

and set Skew to 20.0 and Skew Axis to 45.0 grad

 

get from script values

varskew_x=Math.tan(skew_value*to_digrees) *Math.abs(Math.cos(skew_axis_value*to_digrees));

 

varskew_y=Math.tan(skew_value*to_digrees) *Math.abs(Math.sin(skew_axis_value*to_digrees));
and setup my matrix

_m[0 * 4 + 0] = 1.f;

_m[0 * 4 + 1] = skew_x;

_m[0 * 4 + 2] = 0.f;

_m[0 * 4 + 3] = 0.f;

_m[1 * 4 + 0] = skew_y;

_m[1 * 4 + 1] = 1.f;

_m[1 * 4 + 2] = 0.f;

_m[1 * 4 + 3] = 0.f;

_m[2 * 4 + 0] = 0.f;

_m[2 * 4 + 1] = 0.f;

_m[2 * 4 + 2] = 1.f;

_m[2 * 4 + 3] = 0.f;

_m[3 * 4 + 0] = 0.f;

_m[3 * 4 + 1] = 0.f;

_m[3 * 4 + 2] = 0.f;

_m[3 * 4 + 3] = 1.f;

I got the wrong result, who knows how to correctly get the "skew" values? Perhaps another matrix is needed here?

Thanks, for help!

 


 

How to make a drop down list with the comps preset ?

$
0
0

I think all is in the title.

I'm looking for a way for the user to select the comp preset he prefers for a new comp but without the new comp window.

Also, any suggestions on how to store this information for AE ? txt file ? xml ? etc...

Thanks a lot

Target multiple applications one after the other with a single script

$
0
0

I am trying to make a script that targets illustrator, once its finished it targets after effects. When I run this it targets After Effects instead of illustrator even though runScriptIllustrator(); is called first.

 

function runScriptIllustrator(){

#target illustrator;

    alert ("Hello Ai");

   

}

runScriptIllustrator();

 

 

function runScriptAE(){

#target aftereffects; 

alert("Hello AE");

}

 

runScriptAE();

afterfx command line "restores" maximized window - any way to duplicate ExtendScript invocation?

$
0
0

Hi all,

 

I am controlling After Effects CC from another application by invoking JavaScript files from the command line. But the command *always* restores the maximized window of After Effects. That is, if the After Effects application is maximized, it always *restores* it, every time I invoke the JavaScript file through the command line (e.g. through Windows cmd prompt or through my application). When I execute the same JavaScript file through ExtendScript IDE, it doesn't do this erronous behaviour.

 

For example: "AfterFx.exe -r C:\path\showDialog.jsx"

 

Contents of showDialog.jsx:

----------

alert("Showing Dialog from JSX file");

----------

 

My question is: Is there *any way* to mimic what ExtendScript does to invoke JavaScript files?

From listening on Windows processes, it seems that ExtendScript tacks on some JavaScript code, dynamically, to do the execution (i.e. couldn't trace any command line processes/arguments). But I can't seem to figure out what exact JavaScript code it invokes. ExtendScript also seems to be working via Bridge.

 

I get the same "restore window" behaviour when I try to use "-s" argument with the JavaScript expression passed as a string argument or if I use "AfterFx.com" instead of "AfterFx.exe". I couldn't find any documentation for what command line parameters are supported for AfterFx (other than "-r" and "-s") and what Extend Script might be doing exactly to invoke the .jsx files. I managed to take a peek at the executable binary of AfterFx.exe (through a hex editor) and noticed the following switches.

-rquiet, -noerr, -noui, -debug, -livelink, -selflink, -headlessonly, -rquiet, -rq, -mp

 

But I couldn't get the "window restoring" behaviour to stop with any of the parameters.

 

Any advice will be really appreciated.

 

 

Thanks.

Progress Bars On AE CC15

$
0
0

Hi there,

 

 

I'm creating a script that duplicates a folder and all of its items and goes through each comp and replaces its layers, fixes expressions etc... I'm quite a beginner and have been doing quite well till yesterday, creating the progress bar for my script is where I'm stuck. My script's UI is dock-able and it has a button that triggers the script and creates a palette window where the progress bar is shown on. Inside the for loops that takes most of the time that the script needs (the script takes 2-3 minutes for the project I'm testing the script on), I increase both of the maxvalue and the value of the progress bar. So far nothing wrong, but in AE CC15 (my OS is Windows 10) the palette window crashes (I mean by that it shows "(Not Responding)" on the palette window's title bar) after a few seconds thus the progress bar doesn't update itself anymore. When the script finishes the operation, the progress bar goes to its max value right away. I tested the script on AE CS5.5 and that doesn't happen.

 

Why does the palette window crash? Is this a bug in CC15?

 

I don't want to share all of my code here, I don't want my script's source code to be online, so here is something I can share:

{  function TrueFoldersDuplicatorScript (thisObj) {  function CreateProgressBar () { // This function creates the progress bar's palette window  var w = new Window("palette", "Progress", undefined);  var res = "group{orientation:'column', alignment:['fill','fill'],\  Grp: Group{orientation:'row', alignment:['fill','fill'],\  pb: Progressbar{text: 'Progressbar', alignment:['fill','fill']},\  percenText: StaticText{text: '', alignment:['center','center']},\  },\  pbText: StaticText{text: '', alignment:['fill','fill']},\  okb: Button{text: 'Ok'},\  }";  w.grp = w.add(res);  w.grp.Grp.pb.maxvalue = 0;  w.grp.Grp.pb.minimumSize = [250, 10];  w.grp.Grp.pb.value = 0;  w.grp.pbText.text = "Please wait...";  w.grp.Grp.percenText.text = "00.00%";  w.grp.okb.enabled = false;  w.grp.okb.onClick = function () {this.window.close()}  w.center();  w.show();  return {  theText: function(STR){w.grp.pbText.text = STR; w.update()},  thePercnText: function(str){w.grp.Grp.percenText.text = str; w.update()},  w:w,  SetMax: function(max){w.grp.Grp.pb.maxvalue += max; w.update()}, //Resets the max value  Increment: function(){w.grp.Grp.pb.value += 1; w.update()}, //Increases the value   Finished: function(){w.grp.okb.enabled = true;},  pbValue: function(){return w.grp.Grp.pb.value},  pbMaxValue: function(){return w.grp.Grp.pb.maxvalue},  }  }  function ButtonOnClickDuplicateFunction (panel) {  var SelectedItems = app.project.selection;  if (SelectedItems.length === 1 && SelectedItems[0] instanceof FolderItem) {  var PB = CreateProgressBar (); // Calling the function that creates the palette window  var SelectedItems = app.project.selection;  for (var c = 0; c < SelectedItems.length; c++) {  if (SelectedItems[c] instanceof FolderItem) {  var newFolder = DuplicateFolder(SelectedItems[c], PB); //Duplicates the original folder and its content  var copyFolderItems = allItemsInFolder(newFolder); //Every comp, solid, footage in the new folder  var origFolderItems = allItemsInFolder(SelectedItems[c]); ////Every comp, solid, footage in the original folder  PB.SetMax(copyFolderItems.length); //Increases the max value  PB.thePercnText((Math.round((PB.pbValue() / PB.pbMaxValue()) * 10000) / 100).toString() + "%");  for (var k = 0; k < copyFolderItems.length; k++) {  if (copyFolderItems[k] instanceof CompItem) {  PB.SetMax(copyFolderItems[k].numLayers);  PB.thePercnText((Math.round((PB.pbValue() / PB.pbMaxValue()) * 10000) / 100).toString() + "%");  for (var j = 1; j <= copyFolderItems[k].numLayers; j++) {  //Replaces each comp's layers in the new folder using layer.replaceSource()  PB.Increment(); //Increases the value  PB.thePercnText(((Math.round((PB.pbValue() / PB.pbMaxValue()) * 10000) / 100).toString() + "%"));  }  }  PB.Increment();  PB.thePercnText(((Math.round((PB.pbValue() / PB.pbMaxValue()) * 10000) / 100).toString() + "%"));  }  PB.SetMax(copyFolderItems.length);  PB.thePercnText((Math.round((PB.pbValue() / PB.pbMaxValue()) * 10000) / 100).toString() + "%");  for (var g = 0; g < copyFolderItems.length; g++) { //Fixes all the expressions in the new folder  if (copyFolderItems[g] instanceof CompItem) {  for (var t = 1; t <= copyFolderItems[g].numLayers; t++) {  fixExpressions(copyFolderItems[g].layer(t), copyFolderItems, origFolderItems);  }  }  PB.Increment();  PB.thePercnText(((Math.round((PB.pbValue() / PB.pbMaxValue()) * 10000) / 100).toString() + "%"));  }  }  }  PB.Finished();  PB.thePercnText((Math.round((PB.pbValue() / PB.pbMaxValue()) * 10000) / 100).toString() + "%");  PB.theText("All Done!");  }  function DuplicateFolder(Folder, PrB) {  var newFolder = app.project.items.addFolder(Folder.name);  PrB.SetMax(Folder.numItems);  for (var b = 1; b <= Folder.numItems; b++) {  //Duplicates every item in a folder  PrB.Increment();  }  return newFolder;  }  function allItemsInFolder(aFolder) {  var Items = new Array();  //returns an array with everything in a folder  }  function fixExpressions (aProp, copyFolderItems, origFolderItems) {  //Fixes expressions  }  }  function numCopiesTextChange() {  numCopiesTextValue = this.text;  }  function TrueFolderDuplicatorScript_buildUI(thisObj) { //The dock-able UI of the script  var panel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Window Name", undefined, {resizeable:true});  var res = "group{orientation:'column', alignment:['left','top'],\  mainPanel: Panel {orientation:'column', alignment:['fill','fill'],\  FirstGroup: Group{orientation:'row', alignment:['fill','bottom'],\  numCopies: EditText{text: '1', alignment:['left','fill']},\  numCopiesText: StaticText{text: 'Copies', alignment:['left','center']},\  },\  SecGroup: Group{orientation:'row', alignment:['fill','bottom'],\  solidsCheckBox: Checkbox{text: 'Duplicate Solids', value: true, alignment:['left','fill']},\  footageCheckBox: Checkbox{text: 'Duplicate Footage', value: false, alignment:['left','fill']},\  },\  replaceButton: Button{text: 'Duplicate!', alignment:['center','bottom']},\  },\  }";  panel.grp = panel.add(res);  panel.grp.mainPanel.FirstGroup.numCopies.minimumSize = [23,15];  panel.layout.layout(true);  panel.grp.minimumSize = panel.grp.size;  panel.layout.resize();  panel.onResizing = panel.onResize = function () {this.layout.resize();}  solidsCheckBoxValue = true;  footageCheckBoxValue = false;  panel.grp.mainPanel.SecGroup.solidsCheckBox.onClick = function () {solidsCheckBoxValue = panel.grp.mainPanel.SecGroup.solidsCheckBox.value};  panel.grp.mainPanel.SecGroup.footageCheckBox.onClick = function () {footageCheckBoxValue = panel.grp.mainPanel.SecGroup.footageCheckBox.value};  panel.grp.mainPanel.FirstGroup.numCopies.onChange = panel.grp.mainPanel.FirstGroup.numCopies.onChanging = numCopiesTextChange;  panel.grp.mainPanel.replaceButton.onClick = function () {  app.beginUndoGroup("Duplicate Folder");  ButtonOnClickDuplicateFunction(panel);  app.endUndoGroup();  }  return panel;  }  var TrueFolderDuplicatorScriptPal = TrueFolderDuplicatorScript_buildUI(thisObj);  if(TrueFolderDuplicatorScriptPal != null && TrueFolderDuplicatorScriptPal instanceof Window) {  TrueFolderDuplicatorScriptPal.center();  TrueFolderDuplicatorScriptPal.show();  }  }  TrueFoldersDuplicatorScript(this);

}

Thanks!

 

Message was edited by: Osama Sa

please verify that the folder is located in the same directory as the script premiere

$
0
0

Every time i try to open a script which I have permission for, the following error: please verify that the folder is located in the same directory as the script premiere comes up. HELP!

boxText parameters not updating

$
0
0

Hello,

 

I have problem with changing parameters for boxText.

I can manipulate Position and BoxTextSize, but fontSize doesn't change no matter what I write.

At the end of the script I put alert box, and when I check textDocument fontSize it gives me correct value,

but in Comp window, boxText is always the same size.

 

Here is code

(my text string is in variable s1Atxt1OK)

 

var ttPlac = app.project.item(5).layers.addBoxText([1050, 100]);

ttPlac.property("ADBE Transform Group").property("ADBE Position").setValue([880, 800]);

 

var textProp = ttPlac.property("Source Text");

var textDocument = textProp.value;

textDocument.resetCharStyle();

textDocument.resetParagraphStyle();

textDocument.fontSize = 100;

textDocument.fillColor = [1, 1, 1];

textDocument.font = "HelveticaNeueLTPro-BdCn";

textDocument.applyStroke = false;

textDocument.applyFill = true;

textDocument.text = s1Atxt1OK;

textDocument.justification = ParagraphJustification.LEFT_JUSTIFY;

textDocument.tracking = -10;

textProp.setValue(textDocument);

 

// checking with alert that font size is updated (because in comp window it doesn't change)

var box = textDocument.fontSize;

alert(box);

 

Thanks,

Goran


Set new default solids folder with JavaScript

$
0
0

Hello! Is it possible to set other folder to default solids folder with JavaScript command?

Basically this thing, but with JavaScript:

2018-04-13 16_54_32-Adobe After Effects CC 2018 - Untitled Project.aep _.png

eventListner ( ENTER / RETURN ) and MouseScrollButton on Script?

$
0
0

Aloha insane coders.

 

 

I am finalizing an interface and would like to know if it is possible to add an eventListner so that by pressing the "Enter / Return" button the action of the button is also executed. This makes the use of the interface more intuitive. Every time I try to intuitively do this ... when I test the interface.

 

 

Another question is if I can put an event listner in the area of a panel where the content is controlled by a scrollbar. When I use the mouse scrollbutton on top of the scrollbar the button works, but I would like to be able to add an eventlistner when the mouse is over the content too, plus the scrollbar is very slow when using the mouse scrollbutton.

 

 

I am not finding any documentation about it.

 

 

Thanks in advance for your support ...

 

 

Rubens

Is there an alternative IDE to Extendscript Toolkit?

$
0
0

Hi There,

 

I may be the only one who has this opinion, but I'll throw it out there for discussion anyways.  I'm not a huge fan of the Adobe Extendscript Toolkit IDE.  I use it mainly on OSX and there are so many things that are fundamentally flawed with it.  For example, on the OSX version, when you go to change the colors for the document, they list the acutal color names, but if you choose a color that has two words in it, for example "Aqua Marine" nothing changes.  There are other issues I have with it that make it feel like it's a work in progress tha Adobe puts on the backburner.

 

I'm just curious if there is an alternative IDE that people use whereby you can still target the application you are scripting for?  I am a Coda user and would love to see a plugin written for that app.  If you have any suggestions for an alternative IDE for developing in Extenscript, please do post!

 

Thanks for your time and help!    

Need help in converting this script into a ScriptUI string panel?

$
0
0

Hi there,

 

I'd like to work out the most efficient way of converting this script into a string based Script UI panel.

 

Here's the script itself:

 

http://omino.com/pixelblog/wp-content/uploads/2011/12/om_midi.jsx

 

Trying to get the overall script to be layout out with this structure:

 

AfterEffects-ExtendScript-Extensions/ScriptUI Resource String Reference.jsx at master · VinhSonNguyen/AfterEffects-Exten…

 

Can't figure out where to start, can someone give me a hand in the right direction or if it's easier, help convert it for me?

 

Thanks.

How to make my script dockable?

$
0
0

i made a simple after effects script, and i want to know how to turn it to a dockable script...

when i put it in the scriptsUI folder it just shows me 2 screens...

 

here is the script:

 

 


 

//UI Creation
var myWindow = new Window("palette");
var myMessage = myWindow.add("statictext");




myMessage.text = "תסריט להפיכת טקסט. נעשה על ידי איתי אסולין";

var buttons = myWindow.add("panel", undefined, "buttons");

var HebrewThis = buttons.add("button", undefined, "HebrewThis!");
var Cancel = buttons.add("button", undefined, "Cancel");
buttons.orientation = "row";





//UI Creation End.//



//Function creations

//Hebrew this button
HebrewThis.onClick = function(){





app.beginUndoGroup("AddEffect");

var curItem = app.project.activeItem;

var selectedLayers = curItem.selectedLayers;



// check if comp is selected
if (curItem == null || !(curItem instanceof CompItem)){


// if no comp selected, display an alert
alert("בבקשה בחר שכבה");

} else {

// define the layer in the loop we're currently looking at
var myLayer = app.project.activeItem.layer(1);
var curVal = myLayer.property("Scale").value;
myLayer.property("Scale").setValue([-100, 100]);


var Text = selectedLayers[0].Text.Animators.addProperty("ADBE Text Animator");
myText.property("ADBE Text Selectors").addProperty("ADBE Text Selector");
myText.property("ADBE Text Animator Properties").addProperty("ADBE Text Scale 3D").setValue([-100, 100]);
}

// close the undo group
app.endUndoGroup();
}

   







//Hebrew this button ended.

//cancel button
Cancel.onClick = function(){
           



app.beginUndoGroup("AddEffect");

var curItem = app.project.activeItem;

var selectedLayers = curItem.selectedLayers;



// check if comp is selected
if (curItem == null || !(curItem instanceof CompItem)){


// if no comp selected, display an alert
alert("בבקשה בחר שכבה");

} else {

// define the layer in the loop we're currently looking at
var myLayer = app.project.activeItem.layer(1);
var curVal = myLayer.property("Scale").value;
myLayer.property("Scale").setValue([100, 100]);

var myAnim = selectedLayers[0].Text.Animators.property("ADBE Text Animator");
myAnim.property("ADBE Text Selectors").property("ADBE Text Selector");
myAnim.property("ADBE Text Animator Properties").property("ADBE Text Scale 3D").setValue([100, 100]);
}

// close the undo group
app.endUndoGroup();
    }
.show();
-=

AE 2018 15.1 unsigned extensions doesnt open

$
0
0

i'm currently working on my extension, in a new version of AE when i click my extension in extensions panel in does nothing, no errors, etc...

but in AE 2014 is works...

can anyone help?

Event Listeners cause script to crash when Rendering

$
0
0

I'm having a weird issue where Event Listeners are crashing my script whenever After Effects is rendering

 

The script example below updates a staticText to indicate the cursor event Type.  While rendering, if the cursor enters the window the script will crash and the text will no longer update.  If you rerun the script you will see the error "Can not run a script while a modal dialog is waiting for response".

 

Any ideas?

 

function myScript(thisObj){    function myScript_buildUI(thisObj){         //        var w = (thisObj instanceof Panel) ? thisObj : new Window("palette",  "test", undefined, {resizeable: true});            var paletteText = w.add("staticText");                  paletteText.alignment = ["fill", "top"];                paletteText.text = "Mouse Out";            w.addEventListener("mouseout", cursorHandler);            w.addEventListener("mouseover", cursorHandler);            //        //        function cursorHandler (ev){              if(ev.type == "mouseout" && ev.target.constructor.name == "Panel"){                paletteText.text = "Mouse Out";            }            if(ev.type == "mouseover" && ev.target.constructor.name == "Panel"){                paletteText.text = "Mouse Over";            }          }        //        w.onResize = function(){                         this.layout.resize ();        }        //        w.layout.layout(true);        return w;        //           }    var myScriptPal = myScript_buildUI(thisObj);           if((myScriptPal != null) && (myScriptPal instanceof Window)){        myScriptPal.center();        myScriptPal.show();    }
}
//
myScript(this);

Add a tab to a tabbed panel in Extendscript?

$
0
0

Is there any way to have a user add or remove a tab to a tabbed panel via a '+' or '-' button in the scriptUI built in Extendscript?

 

I need the user to be able to add a customizable number of text layers to a comp... which, for organizations sake, means adding removing 'edittext' objects to a tabbedpanel.

 

Is this (or other live updates to the UI) possible in Extendscript?

UI Icon for Frames vs Seconds

$
0
0

Hey all,

 

I'm migrating a lot of my UI over to graphical buttons and wanted to see if anyone had any thoughts on how to represent frames vs seconds.  I'm currently using the obvious F = frames and S = seconds and blanking if there is a better way to graphically represent them. 

 

Thoughts?

 

Thanks in advance!

Calvin

Run a script from Make, headless.

$
0
0
This has come up for me a few times, and each time I found some other way around it. But I'm sure it's possible, I just havent found the incantation.

I want to run an AE script totally headless (no UI, no interaction).

The script might be something like, pseudo-code:

> open("my_project.aep");
> var data = readDataFile("./datafile.txt");
> setTextAndKeyFrames("comp1",data);
> renderMyMovie("comp1","./todaysHeadlines.mov");
> app.quit();

And I want to run it something like:

> afterEffects --script="./myScript.jsx"

I must be thick. But. What is the incantation for this?

Recursive Function after Render is Done

$
0
0

Hi Everyone!

 

First time poster here, thanks in advance for your patience and guidance. So I'm trying to do something that seems pretty basic and repeated googling has not helped. I'm woefully stuck.

 

In my script I need to render several thousand items, so iteratively adding to the render queue and then starting it later does not work. Therefore I'm trying to write a recursive function that's called once the render queue is finished with the current item, so I can delete the comps/renderqueue after each individual render:

 

theRender.onStatusChanged = function() {

  if (theRender.status === RQItemStatus.DONE) {

               theComp.remove()

              theRender.outputModules[1].remove()

    recallRecursiveFunction();

}}

 

With this I get an error, "Method *** may not be called during rendering or callbacks". This being the case, is there a conceivable solution where I can build and render each of the several thousand plus comps individually while clearing them after? Thank you!

AE CC 2014 Dropdown menu width oddness

$
0
0

Anyone come across this before? I've just converted the office production environment over to AECC 2014 last week and I'm noticing some ScriptUI quirks. We're running the latest update, 13.2x49, and I'm seeing that the dropdown menu widths are not consistent from script to script. Legacy viewing doesn't fix this either. These scripts weren't doing this in AECC. All my scripts are built using ScriptUI resource strings, and my dropdown elements are normally simple ['fill', 'top'] style alignments.

 

This image shows two docked panels I'm currently noticing the issue with.

A.png

 

Once I click the dropdown on the left, I get this. It's wider than it should be for autoscaling, but tolerable.

C.png

 

On the right one however, I am getting a dropdown that is WAY too wide. It literally fills the full 1920 screen width. No items in the dropdown have that many characters either.

B.png

Viewing all 2143 articles
Browse latest View live


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