Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Array with Two Dimensinos Expression

  • Array with Two Dimensinos Expression

    Posted by Tiago Cav on June 5, 2015 at 8:25 am

    I want to define each dimension separately.

    Example:

    First, put a “value 1” in [0] dimension.
    (And [1] dimension stay without value, to “Second Array Part” below, define [1] with “value 2”).

    Second, put a “value 2” in [1] dimension.
    (And [0] dimension stay without value, to “First Array Part” above, define [0] with “value 1”).

    Because I will make a if/else condition, I have two variables, and want that each variable define an different dimension.

    In short:
    “variable 1” with “value 1” define dimension [0];
    “variable 2” with “value 2” define dimension [1];

    Completing two dimensions in property.

    A Array divided.

    I know that can: Right Click in Property and “Separate Dimensions”.

    But, I want to do this in way of expression.

    For example, i try this:

    x=152;
    y=326;

    [x,y]

    It’s OK. But I need with two CONDITIONS IF/ELSE with Separeted Dimensions.

    But in the condition if / else, I am required to define the two dimensions. There is the possibility of the condition, set one dimension, leaving the other dimension to another condition?

    Another example:

    w = 23
    h = 34

    if (“some property” == “some value 1”) “[0] dimension” = w; else 0;

    if (“some property” == “some value 2”) “[1] dimension” = h; else 0;

    Thanks.

    Tiago Cav replied 10 years, 11 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    June 5, 2015 at 4:31 pm

    You might be looking for something like this:

    w = 23;
    h = 34;
    if (your condition goes here) x = w else x = value[0];
    if (your other condition goes here) y = h else y = value[1];
    [x,y]

    Dan

  • Tiago Cav

    June 5, 2015 at 4:38 pm

    Great Dan, always perfect in your Work, Thanks! I will make some tests to see if my question is solved.

  • Tiago Cav

    June 5, 2015 at 5:41 pm

    Yes! Work very well! Thank you so much!

  • Tiago Cav

    June 6, 2015 at 1:24 pm

    Dear Dan, if it is not asking too much, I need a help to know why [x,y] (x and y of property) is not being set by the first condition.

    The first Condition is:
    if(compareSize==0)[w/2,value[1]];
    And when is true, no work.

    I want that the priority be of first condition.

    But the property is being defined by the conditions below;
    And the main part that I want to prevent from having higher priority than the above condition is this:

    if (compareSide==1){
    x = n+s;
    }
    else if (compareSide==2){
    x = w/2;
    }
    else if (compareSide==3){
    x = w-s;
    }

    else x=value[0];

    If necessary, I can show a Print Screen.
    Thanks.

  • Dan Ebberts

    June 6, 2015 at 3:25 pm

    If I understand what you’re trying to do, I think you just need to wrap everything after the first condition in an else clause so that it never gets there if the first condition is met:

    if(compareSize==0){
    [w/2,value[1]];
    }else{

    (all that other stuff)

    }

    Dan

  • Tiago Cav

    June 6, 2015 at 5:45 pm

    Yes! That’s exactly what I want, it worked perfectly.

    I make just some alterations and done.

    Thank you very much!

    // Position:

    try{compareSize=thisComp.layer("+").effect("Size")("Layer").index }catch(err){compareSize=0}
    try{compareHeight=thisComp.layer("+").effect("Height")("Layer").index}catch(err){compareHeight=0}
    try{compareSide=thisComp.layer("+").effect("Side")("Layer").index}catch(err){compareSide=0}

    n=0;

    w=1920;
    h=1080;

    p=100;

    p1=95;
    p2=90;
    p3=85;

    p4=5;
    p5=10;
    p6=15;

    s="";

    if(compareHeight==1){
    y=h*p1/p;
    s=w*p4/p;
    }else if(compareHeight==2){
    y=h*p2/p;
    s=w*p5/p;
    }else if(compareHeight==3){
    y=h*p3/p;
    s=w*p6/p;
    }else{
    y=value[1];
    }
    if(compareSize==0){
    x=w/2;
    }else{
    if(compareSide==1){
    x=s;
    }else if(compareSide==2){
    x=w/2;
    }else if(compareSide==3){
    x=w-s;
    }else{
    x=value[0];
    }
    }
    [x,y]

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