Forum Replies Created

Page 1 of 4
  • oh, I just reapplied the 2nd script the exact way than the last time and now it works, so thats great! thanks!
    Yes, shape layers are always tricky with the hierarchy!

    As for the script, I’ve done the split at vertex part simply cycling into the n vertices, creating the n number of shape copies and applying each path your expression, and it works great.
    It made me rethink the way I did the option to add the number of splits. Now it works adding a trim to each path split’s subgroup(but the path length doesn’t vary, only the way the trim reveals it) , but I love the way your expression cuts the path. Even considering baking the expression to have real splits.

    I guess I’d have to work on the P = L.points(); line, (on the expresison side and the script side) so it reads only the array of segments the user enters on the script UI

  • Santi Agustí

    March 6, 2020 at 11:17 pm in reply to: distance from first vertex expressed in 0-100%?

    wow! thank you very much for your effort and expanation!
    my idea is creating a basic script with 3 buttons, each one will divide the path on different ways: N parts with random length each (whose sum is the total length), N parts all equal, and N parts, given by the vertex points.
    I was using this snippet from Paul Conigliaro to get the total path length and then starting with the 3 approaches.

    I did first the random sub lengths with the sum of the total length, and I changed the approach when I realized using the Trim Paths Offset parameter was giving me the 360º as a total length and it could point me to something. My scripting knowledge is pretty basic, so I love to explore different approaches which most of the times goes to dead ends, but I also love to get lost on those.
    So, for this part (“the vertex and segment division”s button), I was just starting to doodle how to approach. I was starting to convert the array of vertex from cartesian coordinates to polar and then see if that could lead me to something, but before going further on that direction I wanted to ask because something was telling me it was not going to be the right direction.

    So, I love your approach, even if it relays on the expression side (the script I have in mind is just using the code to set the amount of path duplicates and needed values in the trim paths offset or end, and having a couple lines for the path dependencies with the master path).
    I couldn’t make the second expression part you wrote work (the code going into whatever property I want to return the percentage), it says Index out of range. But for now its ok, because on this case, applying a simple trim paths below all the subpaths splitted with the expression you wrote, does the work.

    Now I’m going to see how to add via script the amount of shape path copies equal to the amount of vertex (considering these as not variable over the timeline) and then appply the expression on each. It’s more effective than the multiple shapes+trim paths with clamped range I was doing since the beginning.

    Thank you again for your time and knowledge!

  • I had to face a similar problem, and modifying a bit Dan’s code make it work for me, maybe it can suit your needs temporary until a more versed expressionist can bring a cleaner solution than mine.


    p = content("The Path").content("Path 1").path;
    offsete=content("The Path").transform.position;
    v = [];
    pts = p.points();
    for (i = 0; i < pts.length; i++){
    v.push(toCompVec(pts[i]+offsete));
    }
    createPath(v,p.inTangents(),p.outTangents(),p.isClosed());

  • Santi Agustí

    November 7, 2019 at 5:09 pm in reply to: Finding color property of a shape layer.

    Give this a try , this works for me (sorry to make such a mess on the Xavier’s awesome code! I surely added a lot of redundant and messy lines out there, but it works for now)

    the extra code I added looks for any stroke color in the layer and adds a color control and links the stroke color to that color control
    And the name given to the color control effect is the name of the group the stroke belongs to (only the 1st level). If the stroke is outside a group, it has the name of the stroke (usually Stroke 1).
    Ah, it works on all selected shape layers, so you can select a bunch of them.


    function recurseShape(g, groupHandler){
    // g shape layer or group inside a shape ( should have a content property )
    // groupHandler : what do do with each group

    if (!g.content) return; // doesnt apply

    groupHandler(g);

    if (!g.content.property("ADBE Vector Group")) return;

    for (var n=1; n<=g.content.numProperties; n++){
    if (g.content.property(n).matchName==="ADBE Vector Group") recurseShape(g.content.property(n), groupHandler);
    };
    };

    function myHandler1(g){
    // g shape layer or group inside a shape ( should have a content property )

    if (!g.content || !g.content.property("ADBE Vector Graphic - Stroke")) return;

    for (var n=1; n<=g.content.numProperties; n++){
    if (g.content.property(n).matchName==="ADBE Vector Graphic - Stroke"){
    cu=g.content.property(n).property("Color")
    strokename=g.content.property(n).name
    ///
    cc = myLayers[i].Effects.addProperty("ADBE Color Control");
    cc.property("Color").setValue(cu.value);
    cc.name =strokename;

    if (g.matchName==="ADBE Vector Group"){
    krupname=g.name;
    cc.name = krupname + " " + strokename
    }
    cu.expression="effect(\""+cc.name+"\")(\"Color\")";
    //

    };
    };
    };

    app.beginUndoGroup("Collect Colors");
    var comp = app.project.activeItem;
    var myLayers = comp.selectedLayers;

    for (var i = 0; i < myLayers.length; i++){
    myLayers[i].selected = false;
    recurseShape(myLayers[i], myHandler1);
    }

    app.endUndoGroup();

    Now, if any real coder here could give a clean, and more important, could add a function to prevent the code adding the same color control over and over each time you execute the script (in case you add a new group, or stroke, or have updated anyhing inside the shape layer and just want to update the color controls or add the new ones and keep the old ones without adding them again and again), that will be also more than welcome 🙂

  • Hi!
    did you make any new approach on that idea? or finished that script? I’d love to see how that expression for cancelling out its parent’s time remap could look like, specially being applied directly into a prop like position?

    Something like: a comp have some animated layers and a circle layer with keyframed X position going from left to right. Then on the parent comp we apply time remap with several keys, so we can apply that magic expression to the circle layer pos to cancel the remap and we see the circle keep its original speed.

    So it would be like having the inverse of this expression on pos:
    t =comp("retime").layer(thisComp.name).timeRemap;
    valueAtTime(t);

    but I guess that won’t be easy…

  • Hello!
    That’s a question I’d really love to know, too! for now, maybe this temporary approach may work for your scenario, just add the group position as an offset to your values, something like this:


    var pathTOP =content("balloon").content("blue").content("Path 1").path;
    var pathBOTTOM=content("box").content("Path 1").path;
    a=(pathTOP.points(time)[5]);
    b=(pathBOTTOM.points(time)[3]);

    offsetT=content("balloon").transform.position;
    offsetB=content("box").transform.position;

    TL=[a[0]+offsetT[0],a[1]+offsetT[1]];
    TR=[b[0]+offsetB[0],b[1]+offsetB[1]];

    createPath(points = [TL, TR], inTangents = [], outTangents = [], is_closed = false);

    but keep in mind that if you re-group or move the inner group position (in your case, “blue”), the vertex won’t follow that and will have the same issue as you described, so this is only a temporal possible patch until someone come up with a more flexible solution following the absolute position of the selected vertex
    (so even if the shape is grouped, sub grouped, etc, it will always will be attached to that exact vertex with no offsets)

  • Santi Agustí

    June 29, 2019 at 8:24 pm in reply to: createPath and toWorld?

    thank you!!!
    this is gold!!

  • Santi Agustí

    March 25, 2019 at 3:17 am in reply to: Group shapes

    Hi! sorry to bother with the group thing! I was giving a try to the script you posted here with different kind of grouping ( shape layer with 4 pre- groups to group, another shape layer with 3 and 2).
    Then I found a really odd behaviour when applying the script, it generates a group with several unexpected subgroups, it always creates the same pattern, groups inside groups,( and letting one element outside the group and when selecting more than 2 groups to group).

    I added an image to try to make it a bit more clear.

    On the image, I was trying to group the groups (001,002,003,004) into a single group, but everything seemed to work with that strange behaviour

    I also added the same file I was applying the script into, just in case
    13221_groupsmadness.aep.zip

    I don’t know if there is some line to tweak the script to avoif that infinite looping of creating subgroups when calling the command (3741) or maybe its some kind of bug or limitation when grouping via calling the command with the script?

  • Santi Agustí

    January 17, 2019 at 3:10 pm in reply to: expression to layout layers in a grid

    Hi!
    i’m trying to achieve the same with shape groups inside a shape layer, and as far as I could make it work with the X positions, I was not getting to work with the Y.
    Once it reaches the 6th shape, it just goes to the 5th xposition side, and anything happens to Y (and the 6th shape doesn’t position below the 1st one etc)

    this is the code I’m using, taking yours as ref. (Its applied on the rectangle position, not the transform position of the group.)


    origin= content ("cuad " + (parseInt(thisProperty.propertyGroup(3).name.split(" ")[1],10) - 1)).content("Rectangle Path 1").position;
    myN=thisProperty.propertyGroup(2).propertyIndex-1;

    hDist = effect("xOffset")("Slider")
    vDist = effect("yOffset")("Slider")
    numCols = effect("Cols")("Slider");

    myCol = (myN)%numCols;
    myRow = Math.floor((myN)/numCols);

    origin + [myCol*hDist,myRow*vDist]

    any clue on this would be extra welcome, thanks!

  • Santi Agustí

    January 3, 2019 at 1:36 pm in reply to: scripting: fill color same as layer label color?

    thanks Scott for your help!

    I think I found a workaround here https://forums.adobe.com/thread/1354211
    but at the same time, I was thinking on a plan B for that issue (also, maybe the user has a lot of nulls and want more color variety than only repeating 16 from the label color).

    I think for now I will make the shape get a color from the defined palette as you suggested. I wanted to see how to make it work with hex values, just in case I can save nice color palettes as an array of hexadecimal values
    so, from this starting post https://forums.creativecow.net/readpost/227/37767, I adapted it a bit to make it work with the array of desired colors. I added some hex values from the google material palette, and the original 16 label colors coming in AE, so now when I create a shape associated to a null, the base color of the shape will be a random color from that array.

    just in case anyone is interested, there is the piece of code to read the color from an hexadecimal array and apply randomly to the created shape layer (applied to a pseudo effect)

    function hexToColor(theHex){
    var r = theHex >> 16;
    var g = (theHex & 0x00ff00) >> 8;
    var b = theHex & 0xff;
    return [r/255,g/255,b/255,1];
    }
    var colors = ['#FFDE03', '#0336FF', '#FF0266', '#F44236', '#E91E63',
    '#9C27B0', '#673AB7', '#3F51B5', '#2196F3', '#03A9F4',
    '#00BCD4', '#009688', '#4CAF50', '#8BC34A', '#CDDC39',
    '#FFEB3B', '#FFC107', '#FF9800', '#FF5722', '#9E9E9E',
    '#607D8B', '#079D94', '#FFB31A', '#FFA301', '#FF77A8',
    '#29ADFF', '#FF89B5', '#005784', '#2F484E', '#B2DCEF',
    '#E666B3', '#33991A', '#B53838', '#E5BCC9', '#E4D84C',
    '#A9CBC7', '#B3C7B3', '#B3C7B3', '#677DE0',
    '#677DE0', '#4AA44C', '#8E2C9A', '#E8920D', '#7F452A',
    '#F46DD6', '#3DA2A5', '#A89677', '#1E401E'];

    var idx = Math.floor(Math.random()*colors.length);
    colors[idx]
    myHex = (parseInt(colors[idx].slice(1),16));
    var color = hexToColor(myHex);
    // here is where I apply this: myShape.property("ADBE Effect Parade").property("lashape").property("color").setValue(color);

Page 1 of 4

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