Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Set position to composition

  • Set position to composition

    Posted by Victor Ribbs on June 19, 2020 at 8:30 am

    hello,
    I dynamically add compositions (as_msg) in a basic composition (as_comp)
    var comme_comp = app.project.item (1);
    var tels_msg = app.project.item (2);
    I tried to assign positions to each tels_msg but without success. I manage to move the layers contained in tels_msg
    thank you

    // \COMP BASE
    var tels_comp = app.project.item(1);
    // \COMP MESSAGE
    var tels_msg = app.project.item(2);
    ...
    function addMsgs()
    {
    for ( i = 0; i < tels_data.length; i++){
    var _layerCollection = tels_comp.layers;
    var msg_instance = tels_msg.duplicate();
    //var msg_instance.name = "MSG_INSTANCE_"+i;
    var msg_layerCollection = msg_instance.layers;

    addAvatar(i, msg_layerCollection.byName("AVATAR_SHAPE"));
    addInitialName(i, msg_layerCollection.byName("AVATAR_INITIAL"));
    addName(i, msg_layerCollection.byName("SEND_BY"));

    _layerCollection.add(msg_instance);
    }
    }

    Victor Ribbs replied 5 years, 11 months ago 1 Member · 1 Reply
  • 1 Reply
  • Victor Ribbs

    June 19, 2020 at 5:51 pm

    hello,

    I found the solution to my problem.
    the last layer added to layers is always linked in 1

    var msg_position = tels_comp.layer(1).property("ADBE Transform Group").property("ADBE Position");

    function addMsgs()
    {
    var nL = 1;
    var _layerCollection = tels_comp.layers;

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

    var msg_instance = tels_msg.duplicate();
    msg_instance.name = "MSG_INSTANCE_"+i;
    var msg_layerCollection = msg_instance.layers;

    addAvatar(i, msg_layerCollection.byName("AVATAR_SHAPE"));
    addInitialName(i, msg_layerCollection.byName("AVATAR_INITIAL"));
    addName(i, msg_layerCollection.byName("SEND_BY"));

    _layerCollection.add(msg_instance);
    var msg_position = tels_comp.layer(1).property("ADBE Transform Group").property("ADBE Position");
    msg_position.setValue([x_pos, y_pos]);

    nL++;
    y_pos += 120.0;
    }
    }

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