Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Scripting” linking propertyIndex to an Array Index

  • “Scripting” linking propertyIndex to an Array Index

    Posted by Cyril Drouin on March 28, 2018 at 9:54 am

    Hi everyone,

    I’m trying to push my knownledge on scripting more than i can do.
    So I am writing a script for morphing one text layer to another text layer (with the same letters but with different size like regular to bold) and i have an issue.

    I want to copy key frame at time 2 of my first Shape to the other for morphing between each keys.
    I push my keys of the first shape in an Array and for the second shape I have a setValueAtTime
    myprop2.setValueAtTime(2, keysFirstshape[0]);
    It’s working but just with one key shape i imagine i have to feet my number of second keys shape and keys in my array ? but i don’t know how to do that, i spent my last day trying.
    May be it’s not the good solution

    All the code:
    //Selects txt Layers A & B
    var myLayer = app.project.activeItem.selectedLayers;
    var myLayerIndex = new Array();
    var keysFirstshape = new Array();
    //Stores selected Layers in Array
    for (i = 0; i < myLayer.length; i++) {
    myLayerIndex.push(myLayer[i].index)
    }

    /**********************************************************************************************
    Selects Layers in comp and create shape from txt
    ***********************************************************************************************/
    var selLayers = app.project.activeItem.layers;
    //Loops through deselecting them
    for (var j = 1; j <= selLayers.length; j++) {
    selLayers[j].selected = false;
    }
    //Selects targer layer from stored selection
    var targetLayer = app.project.activeItem.layer(myLayerIndex[1]);
    targetLayer.selected = true;

    //txt to shape
    app.executeCommand(3781);

    /**********************************************************************************************
    add key to all shape and copy the values
    ***********************************************************************************************/
    var myLayers = app.project.activeItem.selectedLayers;
    var myLayer;
    for (var i = 0; i < myLayers.length; i++){
    myLayer = myLayers[i];
    if (myLayer instanceof ShapeLayer){
    var myContents = myLayer.property("ADBE Root Vectors Group");
    propertySearch(myContents);
    }
    }

    function propertySearch(a) {
    for (var j = 1; j <= a.numProperties; j++) {
    for (var k = 1; k <= a.property(j).numProperties; k++) {
    if (a.property(j).property(k) == a.property(j).property("ADBE Vector Shape")) {

    a.property(j).property(k).addKey(0); // add key
    var myPath = a.property(j).property(k);
    myPathNumb = a.property(j).property(k).numProperties;
    myPath.setSelectedAtKey = true;
    keysFirstshape.push(myPath.keyValue(1));

    }
    propertySearch(a.property(j).property(k));

    }
    }
    }

    /**********************************************************************************************
    deselected layers and select the other txt layer for transform to shape
    ***********************************************************************************************/

    var selLayers = app.project.activeItem.layers;
    //Loops through deselecting them
    for (var f = 1; f <= selLayers.length; f++) {
    selLayers[f].selected = false;
    }

    var targetLayer2 = app.project.activeItem.layer(myLayerIndex[1]);

    targetLayer2.selected = true;

    //Applies command to selected layer
    app.executeCommand(3781);

    /**********************************************************************************************
    add key value fro the second shape and paste key values of the frist shape
    ***********************************************************************************************/

    var myLayersb = app.project.activeItem.selectedLayers;
    var myLayerb2;
    for (var g = 0; g < myLayersb.length; g++){
    myLayerb2 = myLayersb[g];
    if (myLayerb2 instanceof ShapeLayer){
    var myContentsb = myLayerb2.property("ADBE Root Vectors Group");
    propertySearchb(myContentsb);
    }
    }

    function propertySearchb(t) {
    for (var l = 1; l <= t.numProperties; l++) {
    for (var h = 1; h <= t.property(l).numProperties; h++) {
    if (t.property(l).property(h) == t.property(l).property("ADBE Vector Shape")) {

    var myprop2 = t.property(l).property(h);
    t.property(l).property(h).addKey(0);
    myprop2.setValueAtTime(2, keysFirstshape[0]);

    }

    propertySearchb(t.property(l).property(h));

    }
    }
    }

    Thank you

    Cyril Drouin replied 8 years, 5 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy