Forum Replies Created

Page 49 of 277
  • For a regular 3D layer, you would apply this expression to an effects that whites out your layer (a tint, or a fill for example):

    https://motionscript.com/design-guide/invisible-facing-away.html

    but in your case it looks like you’re using CC cylinder or something ?

    In that case, two layers one that renders the inside, one that renders the outside, and the inside one is made white before the cylinder effect.

  • In a nutshell:

    • we want to know what the sourceRect height of our text -layer is if every character would have an ascender and a descender.
    • We can use a text-animator “character value” that changes the value of every letter to 124 = a pipe symbol “|”
    • Now the sourceRect gives the height we want, but our text has disappeared, we only see pipes.
    • since sourceRectAtTime() is time based, we can keep the text-readable in our comp, as long as there is a known moment in time, one we don’t need in our render, that the characters get changed into pipes. For example, our comp is 10 seconds long, at second 11 we change the characters into ||||.
    • One better trick to do that is to do it in negative time: layers can and do exist before the starting time of a composition. And even though their startingTime is at 0 or later, text-layers still have a “source”, even when the layer is not active. Bonus: we don’t have to worry that we bump into the illegible text when we make the comp longer.
    • The textanimator that changes the characters just needs to be “on” before the start of the comp (off-screen so to speak). You could make 2 hold keyframes for range amount at frame 0 and 1, then shift them left manually by 1 frame. Or use the expression for “amount” I showed you.

  • Not as straightforward as one would think, because Scripts can’t directly see the absolute position of a child (there is no toComp() method in extendscript).

  • Filip Vandueren

    January 27, 2022 at 12:47 pm in reply to: Parent Un-Partented Nulls – A Script I would love!

    This script should do it:

    app.beginUndoGroup("Group-Parent selected Layers");

    gAI = app.project.activeItem;

    gSL = gAI.selectedLayers;

    parentCandidates=[];

    is3D = false;

    // check which layers don't have a parent and store them in an array

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

    l = gSL[i];

    if (l.parent==null) {

    parentCandidates.push(gSL[i]);

    // if any layers is 3D, the Null will need to be 3D too.

    if (l.threeDLayer) {

    is3D = true;

    }

    }

    }

    // if there are any, create a Null.

    if (parentCandidates.length>0) {

    n = gAI.layers.addNull();

    n.threeDLayer = is3D;

    // calculate the average position of the layers

    avgPos=[0,0,0];

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

    l=parentCandidates[i];

    avgPos+=l.position.value;

    }

    avgPos/=parentCandidates.length;

    n.position.setValue(avgPos);

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

    l=parentCandidates[i];

    l.parent = n;

    }

    }

    app.endUndoGroup();

  • And this expression gives you the number of words in your sourceText.

    text.sourceText.split(/\s+/).length-1;
  • Hi Lauren, I’m not entirely sure what stuff needs to be animated and how (for example, floating inside an alpha matte ?).

    But hope this helps:

    Adding this expression on a textlayer, tells you how many visible lines that textlayer has wrapped to:

    h=sourceRectAtTime().height;
    st=text.sourceText.style;
    ld = st.autoLeading ? st.fontSize*1.2 : st.leading;
    numLines = Math.round(h/ld);

    You can then maybe use that number in your textanimators based on lines.

  • The way I usually fix things like this (ie. I want the sourceRect to not change based on the absence or presence of ascenders and descenders in the font) is to add a pipe symbol to the start or end of the sourceText (value+”|”), and make them invisible with a textanimator setting the last character’s opacity to 0.

    Or alternatively: use a text-animator to set every Character Value to 124 (the Ascii code of “|”).

    Then, only enable the animator’s range before time=0, by giving its range selector’s -> Advanced-> Amount property this expression: “time<0 ? 100 : 0;”

    Now you can check sourceRectAtTime(-1) to know how tall the layer would be if all its characters were pipes 🙂

  • In this case, you could replicate turbulent displace with a regular displacement effect that references a noise map.

    You can then use a 2nd fractal noise layer to mix in patches of 50% gray: 50% = no displacement.

  • Filip Vandueren

    December 14, 2021 at 7:54 am in reply to: Saving the result of a script as a global variable

    If there are multiple values that need to be shared, or if it is a string, or an array, etc. it would be cumbersome to add mulitple sliders.

    I often use (hidden) text-layers for this. The sourceText expression would have some calculations and yield a JSON object, other expressions will parse that JSON object fromt he sourceText and get the properties they need.

    for example, sourceText of layer “globaltxt”:

    globals = {};

    globals.a= Math.sqrt(time);

    globals.pos = [Math.random(100,100), globals.a*5];

    globals.description = time < 2 ? "hello" : "goodbye";

    JSON.stringify(globals);

    in other expressions:

    globals = JSON.parse(thisComp.layer("globaltxt").text.sourceText.value);
    globals.description + " " + globals.a;

  • Here’s my project that does it with a shape instead of write-on:

Page 49 of 277

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