Forum Replies Created

Page 28 of 32
  • Xavier Gomez

    February 6, 2013 at 6:32 pm in reply to: Linking Keyframes between two different comps

    Expressions cannot modify keyframes.

    Either use a script that can move a bunch of keyframes at once (https://www.redefinery.com/ae/view.php?item=rd_Scooter) or leave the keyframes as they are and use a valueAtTime expression for one of the property (either main comp either precomp).

    Xavier

  • Assuming that :
    1- your script has already identified the layer (let’s call it theLayer),
    2- your script has a string variable (called say expr) that contains the expression text,
    you can go on like this:

    var prop = theLayer.transform.position;
    prop.expression = expr;
    prop.expressionEnabled = true;

    if you want need your script to read the property’s values at a given time t, it is like this:

    – for pre-expression value: prop.valueAtTime(t, true)
    – for post-expression value : prop.valueAtTime(t, false)

  • Xavier Gomez

    January 30, 2013 at 3:32 pm in reply to: Sine wave on effect parameter?


    amplitude = 360;
    period = 2;
    refTime = inPoint;

    amplitude * Math.sin(2*Math.PI*(time-refTime)/period);

    amplitude is the amplitude of oscillations, period is the duration of a cycle (in seconds), refTime is the time (in seconds) at which you want the oscillation to have 0 amplitude. Change these numbers according to your needs.

    Don’t enter a period of 0, this will generate an error.
    Note : the best suited forum for this kind of questions is the After Effects expressions forum…

  • Hello,
    i forgot something essential in the code above: before the for() loop you can add this line:
    app.beginUndoGroup("expr. to value")
    and after the loop (so, just before the enter; instruction) add this other line:
    app.endUndoGroup()

    In case you feel sorry about applying this script (better think twice since there is no way back, so it’s not a very safe script) the script action appears in the history under only one label and you can undo the whole lot in just one undo.

    For the shape layers it is quite clumsy since a shape layer property tree can be arbitrarily long (just add a tower of subgroups).
    And writing a script that always treats Ellipses in Group1 is not too useful.
    To know how to refer properties, download the script rd_GimmePropPath

    For instance, for layer = app.project.activeItem.selectedLayers[n], and properties refered by name:

    Content : layer.property(“Contents”)
    Group 1 : layer.property(“Contents”).property(“Group 1”)
    Group 1/Ellipse 1 : layer.property(“Contents”).property(“Group 1”).property(“Contents”).property(“Ellipse Path 1”)

    For loops it is better to refer properties by index though.

    Below is a script that scouts all selected layers and, when the layer is a shape layer, scouts all its properties and when the property is the position property of a Shape (rectangle, Ellipse etc) disables the expression and sets the value.
    You can change var propToReplace = “Position”; to the property you want to replace, for instance var propToReplace = “Scale”.

    Xavier

    function myOtherScript()
    {
    function scout_and_replace(propertyBase, stringKey)
    {
    if(propertyBase.propertyType === PropertyType.PROPERTY)
    {
    var prop = propertyBase;
    if (prop.name.indexOf(stringKey) != -1 && prop.parentProperty.matchName.indexOf("ADBE Vector Shape") != -1)
    {
    if (!prop.numKeys && prop.expressionEnabled)
    {
    x = prop.valueAtTime(inPoint, false);
    prop.setValue(x);
    prop.expressionEnabled = false;
    }
    }
    return;
    }
    else
    {
    var propGroup = propertyBase;
    var numProps = propGroup.numProperties;
    for (var j=1; j<numProps+1; j++)
    scout_and_replace(propGroup.property(j), stringKey);
    return;
    }
    }
    /* */
    if (!Object.isValid(app.project) || typeof app.project.activeItem === 'undefined' || !(app.project.activeItem instanceof CompItem)) return;
    var comp = app.project.activeItem; var selectedLayers = comp.selectedLayers;
    if (!selectedLayers.length) return;

    var numSelectedLayers = selectedLayers.length;
    var layer, inPoint, prop, x;
    var propToReplace = "Position";

    app.beginUndoGroup("script")
    for (var n = 0; n<numSelectedLayers; n++)
    {
    layer = selectedLayers[n];
    inPoint = layer.inPoint;
    if (Object.isValid(layer.property("Contents"))) scout_and_replace( layer.property("Contents"), propToReplace );
    }
    app.endUndoGroup()
    return;
    }

    myOtherScript();

  • What you are asking for is very specific and i don’t think there is a script that does it. The main problem is to decide what properties to scout in the composition (only positions? only transform properties ? all including effects, masks, layerStyles, etc… ?) Scouting absolutely everything over 500 layers can be terribly long, and also useless, if in the end you only want 2-3 specific properties.
    If you know precisely what properties should be scouted the script itself isnt too difficult to write. Below is an example without any UI nor anything, for just position. If you want the script to treat other properties you’ll have to create a “subloop” over the desired properties.
    Re-enabling the expressions can be done similarly, however it is more tricky than it may seem and in practice it is not possible, unless you know what were the original pre-expression values of the properties.

    Xavier.

    function myScript()
    {
    if (!Object.isValid(app.project) || typeof app.project.activeItem === 'undefined' || !(app.project.activeItem instanceof CompItem)) return;

    var comp = app.project.activeItem;
    var selectedLayers = comp.selectedLayers;
    if (!selectedLayers.length) return;

    var numSelectedLayers = selectedLayers.length;
    var layer, inPoint, prop, x;
    for (var n = 0; n<numSelectedLayers; n++)
    {
    layer = selectedLayers[n];
    inPoint = layer.inPoint;
    prop = layer.transform.position;
    if (!prop.numKeys && prop.expressionEnabled)
    {
    x = prop.valueAtTime(inPoint, false);
    prop.setValue(x);
    prop.expressionEnabled = false;
    }
    }
    return;
    }

    myScript();

  • Xavier Gomez

    January 19, 2013 at 2:39 pm in reply to: sampleImage() disables multiprocessor rendering?

    In fact all javascript-based features (so all expressions) can only use one thread, and they are also slower since they are interpreted on the fly. This has nothing to do with sampleImage itself.

  • Xavier Gomez

    January 18, 2013 at 10:32 pm in reply to: sampleImage() disables multiprocessor rendering?

    or memorize the value (!), disable the expression and write the value in the property value slot.

  • Xavier Gomez

    December 31, 2012 at 11:39 am in reply to: Reloading the “Create UI” code

    Hello,
    i’m not sure i can help you more than that… i tried your code and it doesnt show the palette for me. (result: [object Window] and that’s all). However if i write pal.show() instead of simply pal at the end, it does show the palette.

    Also for alignments and item positions in the palette, i’m not used to coordinates, it seems extremely clumsy and hard to modulate. I have no idea why entering orientation/alignment instructions doesnt work for you (such as ventana.stackgroup = ventana.add(“group {orientation: ‘stack’}”); etc). Maybe a version issue but i doubt it (i’m using CS5.5).

  • Xavier Gomez

    December 30, 2012 at 11:22 am in reply to: Reloading the “Create UI” code

    I don’t know if it is a good idea to add/remove items from the palette once it is created and shown. But there is another possiblility:
    Use groups in ‘stack’ (instead of ‘row’ or ‘column’) orientation and play with the visiblity of subgroups.

    for instance:

    ventana.stackgroup = ventana.add(“group {orientation: ‘stack’}”);

    ventana.stacksubgroup1 = ventana.stackgroup.add(“group {orientation:’row’}”);
    ventana.stacksubgroup1.add(“statictext”,[10, 40, 90, 60], “A TOOL”);
    ventana.stacksubgroup1.add(“edittext”,[100,40,180,60],”Sin Nombre”);

    ventana.stacksubgroup2 = ventana.stackgroup.add(“group {orientation:’row’}”);
    ventana.stacksubgroup2.add(“statictext”,[10, 40, 90, 60], “B TOOL”);
    ventana.stacksubgroup2.add(“edittext”,[100,40,180,60],”Sin Nombre”);

    Then in the onChange() function you specify the visibility of subgroups:

    ventana.stacksubgroup1.visible = (toolSelection==0);
    ventana.stacksubgroup2.visible = (toolSelection==1);

    ———–
    Acutally if your selection list is big you can organize subgroups in arrays.
    Create an array of selections (of length, say, numSelectionItems), an array of names (for static text) another array (say: sinNombre) for edit text,then:

    ventana.stacksubgroup = [];
    for (var k=0; k

  • You should probably ask this question in the normal after effects forum: https://forums.creativecow.net/adobeaftereffects. You’ll get more views and more chances for an answer.

Page 28 of 32

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