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

Collect function causes script to go into infinity loop

$
0
0

I'm trying to modify this script and add a collect function I found.
For one selected comp this script works but I would like to make it work with all comps selected.

 

If you comment out line number 230 (collect(projectDir.absoluteURI+ "/" + mycomp,mycomp);

This script does create a folder and saves a reduce project inside the folder.
I think it has something to do with calling "app.project.numItems" on line 96.

But with line 230 uncommented it will do the first comp and then start "3" comps later and goes in a infinity loop...
For testing purposes you can easily create a new project, create a comp, duplicate it a couple of times, select all comps, save it somewhere and run this script.

Alscollect(projectDir.absoluteURI+ "/" + Alsmycomp,mycomp);collect(projectDir.absoluteURI+ "/" + mycomp,mycomp)

 

// rd_NewProjectFromComp.jsx
// Copyright (c) 2007-2013 redefinery (Jeffrey R. Almasol). All rights reserved.
// check it: www.redefinery.com
//
// Name: rd_NewProjectFromComp
// Version: 1.2
//
// Description:
// This script saves separate projects for each selected
// composition.
//
// Note: This script requires After Effects 7.0 or later.
//
// Originally requested by David Torno.
//
// Legal stuff:
// This script is provided "as is," without warranty of any kind, expressed
// or implied. In no event shall the author be held liable for any damages
// arising in any way from the use of this script.
//
// In other words, I'm just trying to share knowledge with and help out my
// fellow AE script heads, so don't blame me if my code doesn't rate. :-)








// rd_NewProjectFromComp()
//
// Description:
// This function contains the main logic for this script.
//
// Parameters:
// None.
//
// Returns:
// Nothing.
//
(function rd_NewProjectFromComp()
{
  // Globals  var rd_NewProjectFromCompData = new Object(); // Store globals in an object  rd_NewProjectFromCompData.scriptName = "rd: New Project From Comp";  rd_NewProjectFromCompData.scriptTitle = rd_NewProjectFromCompData.scriptName + " v1.2";  rd_NewProjectFromCompData.strHelp = {en: "?"};  rd_NewProjectFromCompData.strSaveProjFirst = {en: "Click OK to save the current project."};  rd_NewProjectFromCompData.strSaveInstructions = {en: "The current project will be reduced to each selected composition (and its assets). Please specify a project file name for each one. Click OK to begin."};  rd_NewProjectFromCompData.strErrNoCompsSel = {en: "Cannot perform operation. Please select at least one composition in the Project window, and try again."};  rd_NewProjectFromCompData.strMinAE70 = {en: "This script requires Adobe After Effects 7.0 or later."};  rd_NewProjectFromCompData.strHelpText =  {  en: "Copyright (c) 2007-2013 redefinery (Jeffrey R. Almasol). \n" +  "All rights reserved.\n" +  "\n" +  "This script saves separate projects for each selected \n" +  "composition.\n" +  "\n" +  "Note: This script requires After Effects 7.0 or later.\n" +  "\n" +  "Originally requested by David Torno.\n"  };  // rd_NewProjectFromComp_localize()  //  // Description:  // This function localizes the given string variable based on the current locale.  //  // Parameters:  //   strVar - The string variable's name.  //  // Returns:  // String.  //  function rd_NewProjectFromComp_localize(strVar)  {  return strVar["en"];  }  function collect(dir,prname) { //dossierRassembler, c'est le dossier de destination, plan, c'est une chaine de caractre : le nom du projet/numŽro du plan, ou n'importe quoi d'autre dŽfini par l'utilisateur
      //crŽer le dossier du plan
    var projectDir = new Folder(dir);    var footageDir = new Folder(projectDir.absoluteURI + "/(Footage)/");    projectDir.create();    footageDir.create();      //pour chaque item, si c'est un footage Item, le copier au nouvel emplacement dans le bon sous dossier puis le relinker    var item;    var targetFile;      for (i = 1; i <= app.project.numItems; i++)    {        var item = app.project.item(i);        if (item instanceof FootageItem)        {            //crŽer le dossier
            var targetDir = new Folder(footageDir.absoluteURI + "/" + item.parentFolder.name + "/");            if (!targetDir.exists)                targetDir.create();            if (item.file != null && !item.footageMissing)            {                var extension = item.file.name.substring(item.file.name.lastIndexOf(".")+1).toLowerCase();                if (item.mainSource.isStill) // si c'est fixe                {                    targetFile = new File(targetDir.absoluteURI + "/" + item.file.name);                    if (!targetFile.exists)                    {                        //dŽplacer
                        item.file.copy(targetDir.absoluteURI + "/" + item.file.name);                                          //relink                        item.replace(targetFile);                        }                    }                  else if (extension != "jpg" && extension != "jpeg" && extension != "png" && extension != "tga" && extension != "tif" && extension != "tiff" && extension != "exr" && extension != "bmp" && extension != "pxr"  && extension != "pct"  && extension != "hdr" && extension != "rla"  && extension != "ai" && extension != "cin" && extension != "dpx") {// si c'est pas un format d'image fixe                                        targetFile = new File(targetDir.absoluteURI + "/" + item.file.name);                    if (!targetFile.exists)                    {                        //dŽplacer
                        item.file.copy(targetDir.absoluteURI + "/" + item.file.name);                        //relink                        item.replace(targetFile);                        }                      }                else                { // reste les sŽquences d'images
                    //copie et remplacement en cas de sŽquence de fichier
                      //rŽcupŽrer la liste des images et crŽer le nouveau dossier de destination
                      var dossierSequence = item.file.parent;                      var frameSequence = dossierSequence.getFiles();                      var dossierSequenceTarget = new Folder(targetDir.absoluteURI + "/" + dossierSequence.name + "/");                      dossierSequenceTarget.create();                      targetFile = new File(dossierSequenceTarget.absoluteURI + "/" + item.file.name);                      if (!targetFile.exists)                      {                        //copier les frames                        for (j=0;j<frameSequence.length;j++)                        {                                                    frameSequence[j].copy(dossierSequenceTarget.absoluteURI + "/" + frameSequence[j].name);                            }                        //relink                        item.replaceWithSequence(targetFile, true);                        }                      delete dossierSequence;                      delete frameSequence;                      delete dossierSequenceTarget;                    }                  delete extension;                }              delete targetDir;            }        }    //sauvegarder le projet    //virer les variables    delete projectDir;    delete footageDir;    }  // main code:  //  var projFile = app.project.file;  var fldr = Folder.selectDialog("Choose folder");  //var projectDir = new Folder(fldr);  // Prerequisites check  if (parseFloat(app.version) < 7.0)  alert(rd_NewProjectFromComp_localize(rd_NewProjectFromCompData.strMinAE70), rd_NewProjectFromCompData.scriptName);  else  {  // Make sure only a single comp is selected  if (app.project === null)  return;  // Keep track of item numbers (not actual items, as we need to reload the project after each time)  var comps = new Array();  var compsname = new Array();  for (var i=1; i<=app.project.numItems; i++)  {  if (app.project.item(i).selected && (app.project.item(i) instanceof CompItem))  comps[comps.length] = i;  compsname[i] = app.project.item(i);  $.writeln(i);  }  for (var i=0; i<comps.length; i++)  {  // Reduce project  $.writeln(comps.length);  mycomp = app.project.items[comps[i]].name;     var projectDir = new Folder(fldr);     var footageDir = new Folder(projectDir.absoluteURI + "/" + mycomp + "/");     projectDir.create();    footageDir.create();  app.project.reduceProject(app.project.items[comps[i]]);                collect(projectDir.absoluteURI+ "/" + mycomp,mycomp);                myfile = projectDir.absoluteURI + "/" + mycomp + "/" + mycomp  +".aepx";                                              app.project.save(new File(myfile));  // Reopen project  app.open(projFile);  }  app.endUndoGroup();  }
})();

app events

$
0
0

Hi

 

I just downloaded Plexus3. It creates a dockable panel with content that changes depending on which layer you select. If you select a layer with plexus objects, they will show these in the dockable panel.

 

How are they doing that? They must be catching events from the AE UI. I thought that was impossible.

So question is: How can I get an event from the UI when the user selects a layer or changes composition?

 

Thanks,

Jakob

windowObj .update() issue with dockable panel

$
0
0

Hi community,

 

maybe this is a dump question, but I'm running into an error which I can't solve:

 

I have a script which runs for a couple of seconds. During this, it looks like it hangs, but it's processing things. To make this clear, I changed the text of the execution-button from "Go!" to "processing..." by using the update() function.

 

The UI is builded this way:

<code>

 

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

myPanel.alignChildren = ['fill', 'fill'];

container = myPanel.add('group');

container.orientation = 'stack';

mainres = [...]  // ressource string with all elements

mainPanel = container.add(mainres);

aboutres = [...] // ressource string with additional elements

aboutPanel = container.add(aboutres);

 

 

Now I say:

mainPanel.groupOne.startBtn.onClick = function(){

     mainPanel.groupOne.startBtn.text = "processing...";

     myPanel.update();

     dothemagicfunction();

};

 

[...] // rest of code

 

</code>

 

This works perfectly when the script is running as a floating window. As soon as I start the script from the ScriptUI Panels Folder, which gives me a dockable panel, the code hangs after the update() function. So, the magic is not happening.

 

Does the update function only works with floating windows?

 

Thanks, Martin

make password to script

$
0
0

Hi,

 

How can I make password to my script like this (or something else that will give me the same result)?

 

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.");
    }
}

Copy layer to another composition

$
0
0

Hi all,

 

I am trying to import a specific layer from one AE project to another.

I am able to import AE project and find a composition and add it to where I want with:

 

myComp.layers.add(app.project.item(c).item(e));

 

But how can i go one level down and target specific layer? I tried:

 

myComp.layers.add(app.project.item(c).item(e).layer(1));

 

But i get an error: "[object AVLayer] is not of the correct type".

 

Thanks for your help,

Martin

Remove outline from button in AE cc 2017

$
0
0

Hi,

 

In new AE version (cc 2017) shows a button (in my UI panel that I have created) with outline,

How can I remove the outline or to control the roundness?

outline.PNG

Personal Libraries

$
0
0

Hi there- I haven't set up my own library of functions yet- my code was relatively simple, but now would like to improve my abstraction. So just wondering what people favour for libraries?...  I see there is extendscript include and I am thinking about using the startup folder.

 

I think I will just create multiple files, and make them global (I am only spoiling my own global space - on export I will copy required functions). That's the way I work in Maya . . . and it works for me.  Any workflows for comparison ? ps. I am not trying to write gigantic software, just intelligent, organised code.

 

Thanks!

A


Converting a precomp into 3d via extendscript?

$
0
0

Am developing a script for my own usage in which I have created a precomp via extendscript and now I want to enable 3D for the particular precomp.

 

myComp.draft3d = true;

 

doesn;t work for me!

ScriptUI panel doesn't display name given.

$
0
0

Hi,

 

I'm currently working on a script for After Effects to speed up both my and other people's workflow when creating a certain type of motion graphics. I've developed all the functions needed in their own scripts and I'm now starting to put it together by adding in the UI using resource strings from a template created by VihnSon over at VisualDojo. However, I've come across an issue. What I'm doing for one part of the UI is containing a couple of groups within a panel for layout purposes. When I do this, the text that I'd given the panel within the script changes to "[object Group]" despite being named something different when being created. I don't believe this is just a problem with After Effects as when running the script straight from ExtendScript Toolkit with ExtendScript Toolkit CC selected as being the runtime environment, this object still occurs. I therefore believe that there's a problem somewhere within my code. I've attached both the code and a screenshot of the UI below. Any help is appreciated.

 

//UI building and structure.
{   function myScript(thisObj) {      function myScript_buildUI(thisObj) {                var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "IMT", [0, 0, 300, 300]);                res = "group{orientation:'column', alignment:['fill', 'top'], alignChildren:['fill', 'top'],\                        elements: Panel{text:'Add Elements', orientation:'column', alignChildren:['fill', 'top'],\                            backingCheck: Checkbox{text:'Add Backing'},\                            barsCheck: Checkbox{text:'Add Black Bars'},\                            fadesCheck: Checkbox{text:'Add Fades'},\                            smokeCheck: Checkbox{text:'Add Smoke'},\                            particlesCheck: Checkbox{text:'Add Particles'},\                            rsmbCheck: Checkbox{text:'Add RSMB'},\                            shakeCheck: Checkbox{text:'Add Background Shake'},\                            elementsButton: Button{text:'Add Selected Elements'},\                        },\                        trimPaths: Panel{text:'Trim Paths', orientation:'row', alignChildren:['fill','top'],\                            text: Group{text:'Trim Paths', orientation:'column', alignment:['left', 'top'], alignChildren:['left', 'top'],\                                startText: StaticText{text:'Start'},\                                endText: StaticText{text:'End'},\                            },\                            sliders: Group{text:'Trim Paths', orientation:'column', alignment:['left', 'top'], alignChildren:['left', 'top'],\                                startSlider: Slider{value:0,minvalue:0, maxvalue:100},\                                endSlider: Slider{value:100,minvalue:0, maxvalue:100},\                            },\                        },\                        strokes: Panel{text:'Stroke Type', orientation:'row', alignChildren:['fill', 'top'],\                            flatStrokeButton: Button{text:'Flat'},\                            roundedStrokeButton: Button{text:'Rounded'},\                        },\                }"                // Adds resource string to panel.                myPanel.grp = myPanel.add(res);                               // Assign function to UI elements                // Setup panel sizing and make panel resizable                myPanel.layout.layout(true);                myPanel.grp.minimumSize = myPanel.grp.size;                myPanel.layout.resize();                myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}                return myPanel;      }      // Build script panel      var myScriptPal = myScript_buildUI(thisObj);      if ((myScriptPal != null) && (myScriptPal instanceof Window)) {          myScriptPal.center();          myScriptPal.show();       }   }   // Execute script   myScript(this);
}

 

Screenshot_1.png

refresh startup scripts...

$
0
0

Hi there, just wondering how the AE Data model can be updated . . I see when working in Extendscript if I run a script it updates in the Global space, but when I run a script in Sublime or an external editor and send to AE using -r somefile.jsx, then the global space isn't updated. I can use the $.evalFile, and that works. Just wondering what others do ?  I could script something to re eval all files in the startup folder I suppose....

remove full folder from computer

$
0
0

Hi,

 

I can remove empty folder from my computer with scripting,

But if folder is not empty the function  does not work,

How can I remove full folder?

 

my function is:

{

var folderpath = "~/Desktop/test";

var MyFolder = Folder (folderpath);

MyFolder.remove();

}

How to change color of a Tint fx with $.colorPicker?

$
0
0

I actually have this but doest work. Im trying to make a color picker from my Script to change the color of a Tint FX value.

var defaultColor = 0xff0000;
var color = $.colorPicker(defaultColor);

myPanel.grp.myButton.onClick = function()


{
    app.project.item(1).layer("Dark Gray Solid 1").property("Effects").property("Tint").property("Map Black To").setValue($.colorPicker)    }

Import PSD sequences as compositions

$
0
0

Hi !

I'm currently working on an After Effects script to speed up my and my colleagues work. We often have to deal with heavy psd sequences to import in After Effects, so I want to be able to select all psd sequences I want to import (stock them in an array) and then import them all at once. But I'm facing a problem with the importation. I want my sequences to be imported as comps, so that I get a folder containing all the layers of my psd. Unfortunatly, I haven't found a way to do that. I succeeded in importing a single psd file as comp, but not an entire sequence.

Here is a basic piece of code:

 

(If the code does not display correctly, I've uploaded here: http://data.over-blog-kiwi.com/0/49/06/92/20161110/ob_ffdcb6_import-sequences-as-comps.txt )

 

 

When I try to import a sequence using this script, it opens the importation window...and does not let me choose the "Import as Comp" option (greyed out).

capture.jpg

Is there anything I'm doing wrong here ?

Thank you !

add a scrollbar to resizeable panel

$
0
0

Hi guys,

 

I want that scrollbar in my code (Attaching) act like scrollbar in the Giff (Attaching)-

  1. The scrollbar will show wen the buttons going outside of the window,
  2. Wen scrollbar is moving all buttons will moving up in Opposite direction.
  3. Scrollbar height size will change from number buttons  that outside of the window.

How can I do this with my code?

 

(I apologize for my Improper English).

ScrollBarRef.gif

{

var filse=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];

var scriptName = "test";

  var btnSize =40;

  var masterBtn;

  var scrollbar;

  var btnGroup;

  var AIBtns;

 

 

function test1(thisObj){

  var myWin = ctrlMaker_buildUI(thisObj);

  if (myWin instanceof Window){

  // Center the palette

  myWin.center();

  // Show the UI

  myWin.show();

  }

  else{

  myWin.layout.resize();

  };

 

 

  //======================================================================================= ===================================

  function ctrlMaker_buildUI(thisObj){

  var myWin = (thisObj instanceof Panel) ? thisObj : new Window("palette", scriptName, [200, 200, 400, 350], {resizeable: true});

 

  scrollbar = myWin.add("scrollbar");//<<<<<<<<<<<<<<<<<<<<  

         masterBtn=myWin.add("button", undefined,"master", {style:"toolbutton"});

         btnGroup = myWin.add("group", undefined);

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

         scrollBar.onChanging = function () {   

            var children = btnGroup.children;   

                var n;   

        for (n=0; n<(numItems ); n++){   

                    children[n].location.y = (n-this.value)*itemHeight;   

                    };   

            };   

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

  AIBtns = [];

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

  AIBtns[i] = btnGroup.add("button", undefined, i);

  AIBtns[i].size = [btnSize, btnSize];

  };

  myWin.onResize =myWin.onResizing = ctrlMaker_doResizePanel;

  myWin.onShow = ctrlMaker_doResizePanel;

  return myWin;

  }

//=================================================================

function ctrlMaker_doResizePanel(){

 

 

  var btnOffset = btnSize + 2;

  var maxRightEdge = myWin.size.width - btnOffset;

  var leftEdge = 2;

  var topEdge = 2;

       

        // Reset the background group container's bounds

        scrollbar.bounds = [ myWin.size.width-22,43,  myWin.size.width, myWin.size.height];

 

 

        masterBtn.bounds = [0, 0, myWin.size.width, 40];

        btnGroup.bounds = [0, 42, myWin.size.width, myWin.size.height];

       

        scrollbar.maxvalue =(10);

        // Reset each button's layer bounds

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

  AIBtns[i].bounds = [leftEdge, topEdge, leftEdge+btnSize, topEdge+btnSize];

  AIBtns[i].size=[btnSize,btnSize];

  leftEdge += btnOffset;

  // Create a new row if no more columns available in the current row of buttons

  if (leftEdge > maxRightEdge){

  leftEdge = 2;

  topEdge += btnOffset;

  };

  };

  };

  };

test1(this);

}


Code driving Welcome Screen seems to interfere with script code.

$
0
0

Hello All,

 

I hope all are well, and thank you for taking the time to read this.  I've encountered an issue with parsing JSON strings when the AE Welcome Screen preference is enabled in Adobe After Effects CC 2015 and later.

 

In my ExtendScript code I include Douglas Crockford's open source implementation of JSON2 to parse strings into JSON objects.  Take the following basic example for parsing a string into a JSON object:

 

#include 'json2.js'
var json_string = '{"equal_char" : "\u003d"}',    object = JSON.parse(json_string);

$.writeln(object.equal_char);  //Outputs the equal character to console

 

This works fine when targeting the code to run in ESTK CC, but when targeting After Effects CC 2017 I found that an error was being thrown by the JSON.parse() function.  As I stepped into the .parse() method while debugging, I found that ESTK did not open the included json2.js file.  Instead, ESTK opened a new tab titled Source 2 that contained code not included in the little script above.  As I looked around the code that was brought up, it had the Adobe Copyright statement and the following towards the head of the file:

 

/**
 * After Effects Host ExtendScript Interface for CCX extensions
 */
CCXWelcomeXSHost_AEFT = {

 

From the looks of it, I thought that AE's Welcome Screen dialog might be somehow overwriting the definitions in the 'json2.js' file.  So, I disabled the Welcome Screen preferences, restarted AE without the Welcome dialog, and targeted ESTK to work in AE.  When I stepped into the .parse() method, ESTK did bring up the json2.js file.  This tells me that the main JSON object / class of functions might defined somewhere within that "After Effects Host ExtendScript Interface for CCX extensions", and sure enough here it is on line 2186 of this Interface for CCX extensions:

 

// Public: `JSON.parse`. See ES 5.1 section 15.12.2.        exports.parse = function (source, callback) {          var result, value;          Index = 0;          Source = "" + source;          result = get(lex());          // If a JSON string contains multiple tokens, it is invalid.          if (lex() != "$") {            abort();          }          // Reset the parser state.          Index = Source = null;          return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result;        };

 

Now, I know this can be fixed by some kind of name spacing, but has anybody ever encountered this?

 

Thanks,

Arie

Move Array to Sub/Nested Folder

$
0
0

Hi guys

 

Firstly, my apologies if this question already exists (I find it hard to believe it does not) but i cannot seem to find a reference to it.

 

I am trying to make my own "Organise Script" so That I can quickly organize my projects to my workplaces specific folder structure within AE.

 

As will be evident I have just started scripting and am really just blindly hacking stuff together from different sources.This is a broken down version of what I have what I have got at the moment

 

This is a broken down version of what I have what I have got at the moment. I have a function ( moveToFolder) which allows me to feed it another function (Arrays which collect specific Items) and then send them to the folder specified. This works great at the level below root or to put it another way to the primary folders but I don't know how to get them into a sub-folder.

 

I make the file structure as such

 

var compFolder = app.project.items.addFolder("Comps");

            var buildCompsFolder = app.project.items.addFolder("Build Comps").parentFolder = compFolder;

            var renderComp = app.project.items.addFolder("Render Comp").parentFolder = compFolder;

 

This does it Job and I get a "Comp" Folder with both the "Build Comps" and "Render Comps" folders within.

 

but when I try to put the respective comps into these sub folders they just end up in the parent folder " Comps".

 

Below is the code. I hope my explanation made some sense. if you need any other info please let me know.

 

Many thanks in advance.

 

// Starts Undo group, builds folders and runs moveToFolder function

app.beginUndoGroup("Move to folder");

 

var compFolder = app.project.items.addFolder("Comps");

            var buildCompsFolder = app.project.items.addFolder("Build Comps").parentFolder = compFolder;

            var renderCompFolder = app.project.items.addFolder("Render Comp").parentFolder = compFolder;

          

    moveToFolder(retrievePrimaryComps(), buildCompsFolder)

    moveToFolder(collectAllPrecomps(), renderCompFolder)

   

app.endUndoGroup();

 

 

 

// Move to Folder function. I Think this is where my problem is

 

function moveToFolder(curItemAry, parentFolderObj){

   

    var aryLength = curItemAry.length;

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

        curItemAry[i].parentFolder = parentFolderObj;

        }

    }

//Then these collect my arrays

 

function retrievePrimaryComps(){

    var allItems, allItemsLength, curItem, primaryCompsAry;

    allItems = app.project.items;

    allItemsLength = allItems.length;

    primaryCompsAry = new Array();

    for(var c=1; c<=allItemsLength; c++){

        curItem = allItems[c];

        if(curItem instanceof CompItem){

            if (curItem.usedIn == false){

                primaryCompsAry.push (curItem)

                }

            }

        }

    if(primaryCompsAry.length> 0){

        return primaryCompsAry;

        }else{

            return null;

       }

    }

function collectAllPrecomps(){

    var itemAry, proj, itemTotal, curItem;

    itemAry = new Array();

    proj = app.project;

    itemTotal = proj.numItems;

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

        curItem = proj.item(i);

        if(curItem instanceof CompItem){

            if (curItem.usedIn.length > 0){

                itemAry.push (curItem);

                }

            }

        }

    if(itemAry.length> 0){

        return itemAry;

        }else{

            return null;

     }

    }

}

BridgeTalk not launching after effects

$
0
0

hi people

 

I'm trying to write a script that will run from ESTK which needs on occasion to quit and then relaunch After Effects.

 

I've managed to successfully send messages to and receive messages from AE when it is open and running but I can't workout how to get an instance of AE to launch if it's not already running?

According to the javascript tools guide simply sending a message should launch the target app if it's not already running but this is not happening

 

var bt = new BridgeTalk;
var targetApp = BridgeTalk.getSpecifier( "aftereffects-14.0");

if( targetApp ) {
    alert("AE exists, about to send message");    bt.target = targetApp;    bt.body = 'app.project.items.addFolder("newfolder");writeLn("should be a new folder added?");app.project.numItems'    bt.onResult = function(returnBtObj) {       alert("the result recieved from AE was: " + returnBtObj.body);    }    bt.send(20)
}

 

and neither does using  .launch

 

var bt = new BridgeTalk;
var targetApp = BridgeTalk.getSpecifier( "aftereffects-14.0");

if (BridgeTalk.getStatus (targetApp)=="ISNOTRUNNING"){
    alert("attempting to launch AE");    BridgeTalk.launch(targetApp);    }

 

I'm on OSX 10.11.5 El Capitan, AE CC17

 

any suggestions greatly appreciated

 

../JL

After Effects CC Script UI issues

$
0
0

Hi there, some information I gleaned from discussions on the Indesign forum.

Might be good to have one thread where various issues are discussed in one place.

Keep in mind these issues being discussed over there are showing up in InDesign not After Effects.

I have not tested these, it's just stuff others are talking about - I have yet to fix my scripts for CC.

So if anybody has info... wishes to discuss....

 

What people are talking about:

 

  • The stacking order on Windows has changed to be the same as the Mac's.
  • Horizontal Scrollbar and Vertical missing issue
  • The unenabled icon button show's as the enabled one and some combination of both of them show when unenabled

     - issues with creation properties - toggle

  • Image positions jump (a pixel) sometimes on clicking a radio button and sizes of panels have shrunk
  • Treeview -  http://forums.adobe.com/thread/1235394?tstart=0
  • - issues with foreground and background colors...
  • Script UI fonts and sizes are locked.
  • many events and listeners such as 'focus' or 'onDraw' not work as they did (or are simply discarded);
  • the layout manager 'stack' orientation now causes weird problems;
  • panels with {borderless:true} creation property are not borderless;
  • other widgets don't support ScriptUIPen and ScriptUIBrush customization anymore;

How do you collect an array by file extension?

$
0
0

Hi guys.

 

How would I go about collecting an array from the project by file extension?

 

Say I wanted to collect all the .ai files or .psd or .jpg...you get the picture.

Viewing all 2143 articles
Browse latest View live


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