Forum Replies Created

Page 41 of 65
  • That is so overcomplicated…
    Here is an expression if you want the x to modify same as front and y to the opposite(I thought you only wanted to move the y position from your initial post); In this expression, the “Tgt_Back” is the layer with the wiggle(i am guessing this one has the [720, 540, 0] values) and the “Tgt_Front” is the one that has inverted y. This is applied to “Tgt_Front” position.

    initialPos = [720, 540, 0];
    wigglePos = thisComp.layer("Tgt_Back").transform.position;
    difference =[wigglePos[0]-initialPos[0], initialPos[1]-wigglePos[1],0] ;

    value+difference

    The idea is this. Value gives you the value of this property before the expression. So you only need to get the difference between the wiggle value and the initial position of the wiggle layer. And just add that to your value. If you want the same direction, you subtract the initial position from the wiggle. If you want different directions, you subtract the other way around(the third row in the expression).

    I’m just trying to make you also understand how this work, not just use it.

    The last row is something like [648, 316, 1] + [xRandomWiggle, -yRandomWiggle,0].

    Andrei
    My Envato portfolio.

  • I cant really re-create your situation to test this, but here is how i think you can solve it. Put this in the back layer’s position

    pos = thisComp.layer("Your fron layer").transform.position; //this is the front layer's position
    startPos = pos.valueAtTime(0); //here you must put a time value that is before the wiggle.
    yDiff = startPos - pos;
    value + [0,yDiff,0];

    Andrei
    My Envato portfolio.

  • Andrei Popa

    January 6, 2020 at 6:17 pm in reply to: Using source text to scale a path

    I think the best way is create a rectangle with no stroke. The height of this rectangle should be the 100% value. Then link it’s height to the source text of the percentage. Something like this, inside the size property. Modify Percentage Layer to what you have in project.

    L = parseInt(thisComp.layer("Percentage Layer").text.sourceText);
    [value[0], value[1]*L]

    Andrei
    My Envato portfolio.

  • Add a fill property with this expression to its color.


    startX = position.valueAtTime(0)[0];
    startY = position.valueAtTime(0)[1];
    hSpeed= 222;
    vSpeed= 200;

    marginh = 76;
    marginw = 175;

    cw=thisComp.width - marginw*2;
    ch=thisComp.height -marginh*2;
    x = startX - marginw + time*hSpeed;
    y = startY - marginh + time*vSpeed;
    s = Math.floor(x/cw)+Math.floor(y/ch);
    seedRandom(s,true);
    random([1,1,1]) + [0,0,0,1]

    Andrei
    My Envato portfolio.

  • Andrei Popa

    January 4, 2020 at 3:26 pm in reply to: Detect if layer was deleted via scripting

    You could use a try/catch block. Something like this


    try {
    var a = app.project.item(1).layer("Shape Layer 1").name;
    alert(a);
    }catch(e){
    alert("You shouldn't delete the layer");
    }

    Another way would be to compare the layer to a null. You must do this before trying to access any of the property. If you do (app.project.item(1).layer(“Shape Layer 1”) == null) you get a true value if the layer does not exist. However, if you try to access any property of a layer that does not exist, you get an error. Something like this doesn’t work (app.project.item(1).layer(“Shape Layer 1”) == null)

    Andrei
    My Envato portfolio.

  • Andrei Popa

    January 4, 2020 at 9:16 am in reply to: Offsetting Position Expression to InPoint Time

    Try modifying your 7th line to this:

    t = linear(time,startDur,endDur,0,1);

    Andrei
    My Envato portfolio.

  • Andrei Popa

    January 2, 2020 at 6:25 pm in reply to: Copy Shape Path to Position Property via Scripting

    There is some black magic going here, I’m telling you. It seems to work on my side. Here are details.

    So what i did:
    Blank project.
    I draw a layer as source for the script created path. I name this layer “Source Path”. This will be layer 3.
    I create a dummy layer that i use for pasting to position property. This will be layer 2.
    I run this first to create a new Shape and paste the vertices from the other “Source Path” layer. This is the code you provided except the first line where i create the layer.


    var shapeLayer = app.project.activeItem.layers.addShape();
    var pathShape = new Shape();
    var pathGroup = shapeLayer.property("Contents").addProperty("ADBE Vector Group");
    pathGroup.name = "path";
    var myPath = pathGroup.property("Contents").addProperty("ADBE Vector Shape - Group");

    verticesArray = app.project.item(1).layer("Source Path")("ADBE Root Vectors Group")(1)("ADBE Vectors Group")(1)("ADBE Vector Shape").value.vertices;
    pathShape.vertices = verticesArray;
    myPath.property("Path").setValue(pathShape)
    pathGroup.moveTo(1);

    Now we have layer one which is a shape layer created by the script and layer 2 which is the dummy to test the position.

    I run this and it works. Turns out you did not need to select the layer before the property. I had this in a larger function and i think i used it for something else.

    function copyPathToPosition(pathLayer, positionLayer){

    var myPosition = positionLayer.property("ADBE Transform Group").property("ADBE Position");
    var myPath = pathLayer.property("ADBE Root Vectors Group").property("ADBE Vector Group").property("ADBE Vectors Group").property("ADBE Vector Shape - Group").property("ADBE Vector Shape");

    myPath.selected = true;
    app.executeCommand(19); //Copy
    pathLayer.selected = false;

    myPosition.selected = true;
    app.executeCommand(20); //Paste
    positionLayer.selected = false;
    }

    L1 = app.project.item(1).layer(1);
    L2 = app.project.item(1).layer(2);
    copyPathToPosition(L1,L2);

    Now you need to figure out what in your project is not like in this project.

    Some things that complicated my stuff in the past:

    Having layers with the same name
    Having properties in the same group with the same name
    Getting the property variable using matchName without index. I had a problem like this where it got only the first shape in a group with multiple shapes.
    A variable of the wrong type. Sometimes I used setValue or the = operator or some sort of methods on 2 variables that were not compatible. Script broke sometimes with no errors shown.

    This is pretty much everything i can get with the information you provided.
    Good luck on your which hunt 😀

    Andrei
    My Envato portfolio.

  • Andrei Popa

    January 2, 2020 at 4:23 pm in reply to: Copy Shape Path to Position Property via Scripting

    I don’t know where your error comes from. I used it like this in a fresh project with 2 layers. I even used the same layer(I copied the Path data to the Position of the same layer) and it worked.


    function copyPathToPosition(pathLayer, positionLayer){

    var myPosition = positionLayer.property("ADBE Transform Group").property("ADBE Position");
    var myPath = pathLayer.property("ADBE Root Vectors Group").property("ADBE Vector Group").property("ADBE Vectors Group").property("ADBE Vector Shape - Group").property("ADBE Vector Shape");

    pathLayer.selected = true;
    myPath.selected = true;
    app.executeCommand(19); //Copy
    pathLayer.selected = false;

    positionLayer.selected = true;
    myPosition.selected = true;
    app.executeCommand(20); //Paste
    positionLayer.selected = false;
    }

    L1 = app.project.item(1).layer(1);
    L2 = app.project.item(1).layer(2);
    copyPathToPosition(L1,L2);

    I assume it may be something other that you use in your script that does not allow the things to happen. Maybe if you give some more details, i can try to figure out why it’s not working.

    I have tested it in AE 2017 and AE 2020

    Andrei
    My Envato portfolio.

  • Andrei Popa

    January 2, 2020 at 3:11 pm in reply to: Copy Shape Path to Position Property via Scripting

    Hi Tomas. Make sure you have nothing selected before running this function.

    function copyPathToPosition(pathLayer, positionLayer){

    var myPosition = positionLayer("Transform")("Position");
    var myPath = pathLayer("Contents")(1)("Contents")(1)("Path");

    pathLayer.selected = true;
    myPath.selected = true;
    app.executeCommand(19); //Copy
    pathLayer.selected = false;

    positionLayer.selected = true;
    myPosition.selected = true;
    app.executeCommand(20); //Paste
    positionLayer.selected = false;
    }

    I use a function like this one to make sure nothing is selected:

    function deselectEverything(myActiveComp) {
    mySelectedItems = myActiveComp.selectedLayers;
    for (i = 0; i < mySelectedItems.length; i++){
    mySelectedItems[i].selected = false;
    }
    }

    Andrei
    My Envato portfolio.

  • You want to modify a video file after you rendered it from AE? If that is so, you can’t. If you want multiple versions, you need to render them all from AE.

    Andrei
    My Envato portfolio.

Page 41 of 65

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