Forum Replies Created

Page 5 of 65
  • Andrei Popa

    September 25, 2022 at 5:13 pm in reply to: Lines that move opposite from another on the Y axis

    I think you should add this to the yPosition of the layer “Bottom Line Right Null”

    zeroPos = 960;
    P = thisComp.layer("Top Line Right Null").transform.yPosition;
    zeroPos + zeroPos - P;
  • Andrei Popa

    September 19, 2022 at 7:37 pm in reply to: How to delete a layer based on its name?

    I think if you move your solid, you should not put the origin in the vertices part. So maybe Shape.vertices should look like this:

    Shape.vertices = [
    - [this.large, 0],
    [this.large, 0],
    [this.large, velen - this.arrowheight],
    [this.large + this.arrowwidth, velen - this.arrowheight],
    [0, velen],
    [-this.large - this.arrowwidth, velen - this.arrowheight],
    [-this.large, velen - this.arrowheight],
    - [this.large, 0]
    ];

    But I would not use solid. Why not use shape layer instead? Something like this may work:

    //The origin is supposed to be the place on screen where the arrow gets placed.
    function Vector(x, y, origin, r, g, b) {
    this.x = x;
    this.y = y;
    this.angle = -myAngle(x, y);
    this.origin = origin;
    velen = Math.round(length(x, y));
    this.length = velen;
    this.r = r;
    this.g = g;
    this.b = b;
    this.lname = "(" + this.x.toString() + "," + this.y.toString() + ")"; //So that the name layer matches the coordinates of the vector.
    this.large = 10; //The arrow base it twice as large
    this.arrowwidth = 7; //
    this.arrowheight = 20;
    var myShape = new Shape;
    myShape.closed = true;
    //The following line is me trying things out :
    myShape.vertices = [
    - [this.large, 0],
    [this.large, 0],
    [this.large, velen - this.arrowheight],
    [this.large + this.arrowwidth, velen - this.arrowheight],
    [0, velen],
    [-this.large - this.arrowwidth, velen - this.arrowheight],
    [-this.large, velen - this.arrowheight],
    - [this.large, 0]
    ];
    myShapeLayer = createShape(this.lname, myShape);
    myShapeLayer.rotation.setValue(this.angle);
    myShapeLayer.position.setValue(this.origin);
    //mySolid.anchorPoint.setValue(origin);
    function createShape(shapeName, shapeValue) {
    var myShape = app.project.activeItem.layers.addShape();
    myShape.name = shapeName;
    var myShapeGroup = myShape.property("ADBE Root Vectors Group");
    var path1 = myShapeGroup.addProperty("ADBE Vector Shape - Group")("ADBE Vector Shape");
    path1.setValue(shapeValue);
    //var myStroke = myShape("Contents").addProperty("ADBE Vector Graphic - Stroke");
    var myFill = myShape("Contents").addProperty("ADBE Vector Graphic - Fill");
    myFill("ADBE Vector Fill Color").setValue([r,g,b]);
    return myShape;
    }
    }
    var myVector = new Vector(12, 12, [0, 0], 1, 1, 1)

    I have tested this without the angle and the length part, as I am missing those functions (I just used square root of the sum of squares for a few tests for length, ignored the angle part).

    Also, as a suggestion. If you do not intend to use your variable outside the function (eg: use myVector.arrowWitdh, myVector.origin etc after declaring myVector) do not declare them with “this.”. That declaration makes them public, and I am not sure you want that.

    LE: What’s up with the thread name? 😀

  • Andrei Popa

    September 16, 2022 at 8:13 am in reply to: Release button after being pressed in ScriptUI

    Hi Vincenzo.

    You could try this. It works most of the times. It does not work when panel object is selected or if nothing is selected. If a composition is selected in the panel, it opens that comp (this may be a little annoying at times).

    Paste this as the last like in your .onClick function.


    if (app.project.activeItem) app.project.activeItem.openInViewer();
  • Try this. You can modify the size as you wish.

    scriptAbout = "all my info with multilines";
    var aboutWindow = new Window("palette", "About Window", undefined, { resizeable: true, closeButton: true });
    aboutWindow.orientation = "column";
    var aboutOne = aboutWindow.add("group", undefined, "aboutOne");
    aboutOne.orientation = "row";
    aboutText = aboutOne.add('edittext {size: [372,66], properties: {readonly:true, multiline: true}}');
    aboutText.text = scriptAbout;
    aboutWindow.show()
  • This should work

    app.beginUndoGroup("myScript");
    var myLayers = app.project.activeItem.selectedLayers;
    for (var i = 0; i < myLayers.length; i++) {
    tryStroke(myLayers[i].property("ADBE Root Vectors Group"))
    }
    function tryStroke(prop) {
    for (var j = prop.numProperties; j >= 1; j--) {
    var subProp = prop.property(j);
    if (subProp.numProperties) {
    $.writeln(subProp.name)
    tryStroke(subProp)
    }
    if (subProp.matchName == "ADBE Vector Graphic - Stroke" && !subProp.parentProperty("Stroke 2")) {
    subProp("ADBE Vector Stroke Color").setValue([0, 0, 0]);
    var str2 = subProp.duplicate();
    str2("ADBE Vector Stroke Color").setValue([1, 1, 1]);
    }
    }
    }
    app.endUndoGroup();
  • Hey. Sorry, I did not test the code. Here is a working version. I changed the second for, because it was going infinite loop

    app.beginUndoGroup("myScript");
    var myLayers = app.project.activeItem.selectedLayers;
    for (var i = 0; i < myLayers.length; i++) {
    tryStroke(myLayers[i].property("ADBE Root Vectors Group"))
    }
    function tryStroke(prop) {
    for (var j = prop.numProperties; j >= 1; j--) {
    var subProp = prop.property(j);
    if (subProp.numProperties) {
    $.writeln(subProp.name)
    tryStroke(subProp)
    }
    if (subProp.matchName == "ADBE Vector Graphic - Stroke") {
    subProp.duplicate();
    }
    }
    }
    app.endUndoGroup();
  • Andrei Popa

    September 6, 2022 at 5:04 pm in reply to: Changing Position keyframes but keeping the speed graph

    I think this will only work correctly if the value of key 2 is bigger than the value of key 1

    x = [100, 200]; // my new keyframe1 value
    y = [200, 300]; // my new keyframe2 value
    if(n == 1) // if true change the position keyframe1 and keyframe2
    {
    v1 = valueAtTime(key(1).time);
    v2 = valueAtTime(key(2).time);
    linear(value[0], v1[0], v2[0], x, y);
    }
    else value
  • This should work

    app.beginUndoGroup("myScript");
    var myLayers = comp.selectedLayers;
    for (var i = 0; i < myLayers.length; i++) {
    tryStroke(myLayers[i].property("ADBE Root Vectors Group"))
    }
    function tryStroke(prop) {
    for (var j = 1; j <= prop.numProperties; j++) {
    var subProp = prop.property(j);
    if (subProp.numProperties) {
    tryStroke(subProp)
    } else {
    if (subProp.matchName == "ADBE Vector Graphic - Stroke") {
    subProp.duplicate();
    }
    }
    }
    }
    app.endUndoGroup();
  • Andrei Popa

    September 5, 2022 at 4:36 pm in reply to: Random reveal of different shapes that keeps changing

    I saw your PNG image after I made the post. I have also made it that the X can have different colors for each / by using essential graphics on the “Slash Comp” and removing the fill.

  • Andrei Popa

    September 5, 2022 at 4:08 pm in reply to: Random reveal of different shapes that keeps changing

    Hi Sylvia.

    I am just trying to see if I understood this well. You have a grid of shapes. Each shape can be one of 4 states: left slash, right slash, both slash or no slash. They change (abruptly, without fading) each n number of seconds. A random value of the 4 I have mentioned. Meanwhile, they also have to change the color. Can a “both slash” state be different colors? I mean an X with each line different? Is there anything else more than this you want to achieve?

    If this is it, you can use this project. I made your comps 4 frames long, and moved the color with a fill, on the main comp.

Page 5 of 65

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