Forum Replies Created

Page 4 of 65
  • Andrei Popa

    January 18, 2023 at 7:56 am in reply to: Need somebody to develop a scrip to change comp length

    It’s possible to make the comp length proportionally to the length of a text (I assume you want to count characters). The 2 are also possible, but you need to be more specific. Do you want some layers inside the comp to fade? Or the comp, somewhere where it is used as a layer.

    Here is a snippet that modifies the length of the current comp according to the number of characters in the first text layer.

    function setCompLength(myComp, framesPerChar) {
    //search first text layer and save character number
    for (var i = 1; i <= myComp.numLayers; i++) {
    var crtLayer = myComp.layer(i);
    if (crtLayer instanceof TextLayer) {
    var numChars = crtLayer.text.sourceText.value.text.length;
    break;
    }
    }
    myComp.duration = framesPerChar * myComp.frameDuration * numChars;
    }
    setCompLength(app.project.activeItem, 10);
  • Andrei Popa

    January 17, 2023 at 12:52 pm in reply to: Control Paragraph Text Box Size by an expression

    I think you can use this function.

    function setBoxSize(myLayer, boxSize){
    var textProp = myLayer("ADBE Text Properties")("ADBE Text Document");
    var textDoc = textProp;
    textDoc.boxTextSize = boxSize;
    textProp.setValue(textDoc)
    }
  • This applies expressions if properties are selected, precomposes if layers are selected, enables time-remap if a layer that is a comp is selected.

    var win = new Window("palette", "My Script UI", undefined);
    // Add a button for the expression
    var myButton = win.add("button", undefined, "Button");
    // Add an event listener for the button's click event
    myButton.onClick = function() {
    // Get the active composition
    var comp = app.project.activeItem;
    // Get the selected properties
    var selProps = comp.selectedProperties;
    if(selProps.length > 0 ){
    // Loop through the selected properties
    for (var i = 0; i < selProps.length; i++) {
    // Get the current property
    var prop = selProps[i];
    // Check if the property is a shape path
    if (prop.propertyValueType == PropertyValueType.SHAPE) {
    // Add the custom expression to the shape path property
    prop.expression = "my custom expression";
    } else {
    // Add the another custom expression to the property
    prop.expression = "my other custom expression";
    }
    // Check if the active item is a layer
    if (comp.activeItem instanceof AVLayer) {
    // Get the active layer
    var layer = comp.activeItem;
    // Precompose the layer
    var precomp = layer.precompose(layer.name, true);
    }
    }
    //if no selected property
    }else{
    var selLayers = comp.selectedLayers;
    //check if only one layer is selected, and if it is a comp
    if(selLayers.length == 1 && selLayers[0].source && selLayers[0].source.typeName == "Composition"){
    selLayers[0].timeRemapEnabled = true;
    }else{
    //get an array with the indexes of the selected layers
    var indices =[];
    for(var i=0; i< selLayers.length; i++){
    indices[i] = selLayers[i].index;
    }
    comp.layers.precompose(indices, "someName", true);
    }
    }
    }
    // Show the window
    win.show();
  • Hi Vicenzo.

    You can try this.

    var win = new Window("palette", "My Script UI", undefined);
    // Add a button for the expression
    var myButton = win.add("button", undefined, "Button");
    // Add an event listener for the button's click event
    myButton.onClick = function() {
    // Get the active composition
    var comp = app.project.activeItem;
    // Get the selected properties
    var selProps = comp.selectedProperties;
    if(selProps.length > 0 ){
    // Loop through the selected properties
    for (var i = 0; i < selProps.length; i++) {
    // Get the current property
    var prop = selProps[i];
    // Check if the property is a shape path
    if (prop.propertyValueType == PropertyValueType.SHAPE) {
    // Add the custom expression to the shape path property
    prop.expression = "my custom expression";
    } else {
    // Add the another custom expression to the property
    prop.expression = "my other custom expression";
    }
    // Check if the active item is a layer
    if (comp.activeItem instanceof AVLayer) {
    // Get the active layer
    var layer = comp.activeItem;
    // Precompose the layer
    var precomp = layer.precompose(layer.name, true);
    }
    }
    //if no selected property
    }else{
    var selLayers = comp.selectedLayers;
    //get an array with the indexes of the selected layers
    var indices =[];
    for(var i=0; i< selLayers.length; i++){
    indices[i] = selLayers[i].index;
    }
    comp.layers.precompose(indices, "someName", true);
    }
    }
    // Show the window
    win.show();

    You need to check if no property is selected, and then precomp the selected layers. You can change the “someName” to any name you want, or you could use selLaters[0].name to use the name of the first selected layers (works even if only one layer is selected).

  • You also need to pass your text to the style property, something like this:

    str = "123" + "\r" + "345"
    text.sourceText.style.setLeading(105).setFauxBold(1).setText(str)
  • Andrei Popa

    November 3, 2022 at 7:45 am in reply to: Reference Comp specifically (and dynamically)

    Hi Paul.

    This may be what you need to use. I have successfully used it in the past.

    True Comp Duplicator – aescripts + aeplugins – aescripts.com

  • Andrei Popa

    November 3, 2022 at 7:38 am in reply to: Control values from two locations

    How would the position property know where to take its values from?

  • Andrei Popa

    October 20, 2022 at 6:10 am in reply to: Scripting – Set Layer Selection

    I think this should work

    var myComp = app.project.activeItem;

    var myLayers = myComp.selectedLayers[0];

    myParent = myLayers.effect("Parent Me")("Select Parent");

    myParent.setValue(3);

  • Andrei Popa

    October 18, 2022 at 6:28 am in reply to: Random values in new line of SourceText

    Something like

    a = []
    for(let i =0; i<5; i++) a.push(random());
    a.join("\n")

  • Andrei Popa

    October 1, 2022 at 6:24 am in reply to: Lines that move opposite from another on the Y axis

    Hi Steven. Here is the explanation.

    zeroPos is the vertical position where you start your vertical animation.

    zeroPos – P is the difference between the starting point and the current point of the other bar.

    We add these and we get the position of the second bar relative to the first one.

    If the first one was going up, zeroPos – P was positiove, and so the position of the second would increase. If the first one was going down, zeroPos – P was negative, and the position of the second would decrease. We just added to zeroPos the difference. If the mirror axes would have been zero, this expression would have been just -P.

Page 4 of 65

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