Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to use Shape Group #s instead of layer index in an Expression

  • How to use Shape Group #s instead of layer index in an Expression

    Posted by Roland R. kahlenberg on October 31, 2013 at 12:00 pm

    I’ve got the following Expression that works fine –

    propInitialSize = thisComp.layer("Controller Layer").effect("Transition Size ")("Slider");
    Scalar = thisComp.layer("Controller Layer").effect("Transition Size Scalar ")("Slider");
    Val = propInitialSize -(5*(index*Scalar));
    [Val,Val]

    I would now like to convert the project using multiple Shape Groups (up to 25, starting from Group 1 to Group 25) instead of layers (up to 25). How would I go about converting the existing script?

    TIA
    RoRK

    Intensive mocha & AE Training in Singapore and Other Dangerous Locations

    Imagineer Systems (mocha) Certified Instructor
    & Adobe After Effects CS6 ACE/ACI

    Sandro Tagliavini replied 3 years, 2 months ago 8 Members · 22 Replies
  • 22 Replies
  • Dan Ebberts

    October 31, 2013 at 7:55 pm

    I think if you replace the third line with this you’ll be close:

    val = propInitialSize -(5*(thisProperty.propertyGroup(2).propertyIndex*Scalar));

    Dan

  • Paul Roper

    November 6, 2013 at 1:11 pm

    Coincidentally, I was wracking my brain with a very similar problem yesterday…and hoping to find a solution to it today.

    (continuing a discussion from over a year ago….!!)
    …but, is there a way to get the number of “this group”?

    I want to do this so I can access the previous group (in the same way I’d use “index-1” to access the previous layer).

    So to get the previous group’s rectangle 1’s position, it would be something like:

    TargetGroup = thisGroup-1;
    content(TargetGroup).content("Rectangle Path 1").position

    ….thisGroup being a magical made-up function that gets the current group’s number or name.

    Any thoughts or suggestions? I’ve created an expression to get a group’s name and increase its last digit by 1:

    theOne="Group "+2;
    thisGroup=thisComp.layer("Shape Layer 1").content(theOne).name;
    thisNumber=parseInt(thisGroup.substr(-1));
    theOne=thisGroup.substr(0,thisGroup.length-1)+(thisNumber+2)

    but without being able to get the current group’s number, it’s not much use. I’m going round in circles!

    – Paul

  • Dan Ebberts

    November 6, 2013 at 3:45 pm

    When you say “group”, do you mean property group, or shape layer group?
    It would help to see a picture of what you’re trying to do. In any case, propertyGroup() is pretty much the only tool you have to move up the hierarchy. It does sound like what you want to do is possible, I’m just not sure what that is.

    Dan

  • Paul Roper

    November 7, 2013 at 10:14 am

    Hi Dan,

    I’ve made a simple example here:

    But instead of Group 2’s rectangle position being:
    content("Group 1").content("Rectangle Path 1").position+[0,100]
    I’d like it to be something like:
    content(THISGROUP-1).content("Rectangle Path 1").position+[0,100]
    …so I can create a lot of these groups and they’ll each reference the group above (and not using the Repeater – I need to add a different fill to each one). In the project I needed this for, I’ve ended up making a lot of layers, achieving the same result (but less elegantly) having each layer reference the position of the “index-1” rectangle. It works, but I’m not a fan of unwieldy multi-layer comps when it can probably be done more concisely with a few lines of an expression.

    – Paul

  • Dan Ebberts

    November 7, 2013 at 5:14 pm

    It’s tricky and very dependent on how you have your groups set up, but in your example, something like this should work:

    content (“Group ” + (parseInt(thisProperty.propertyGroup(3).name.split(” “)[1],10) – 1)).content(“Rectangle Path 1”).position+[0,100]

    Dan

  • Paul Roper

    November 7, 2013 at 5:47 pm

    I can’t find the “SOLUTION!” thing in this thread…because that is, indeed, the solution!*

    The “thisProperty” is the key.

    THANK YOU!

    – Paul

    *Aha! It’s probably because I didn’t start this thread.

  • Roland R. kahlenberg

    November 8, 2013 at 11:58 am

    Bleh! I’m not getting it. 🙁

    Me thinks there should be a groupIndex (or thisGroup) thingy that works analogously to index.

    Intensive mocha & AE Training in Singapore and Other Dangerous Locations

    Imagineer Systems (mocha) Certified Instructor
    & Adobe After Effects CS6 ACE/ACI

  • Vincent Landrieu

    September 9, 2016 at 9:34 am

    Hi,

    Can you please tell me what is the “3” in this expression ?
    content (“Group ” + (parseInt(thisProperty.propertyGroup(3).name.split(” “)[1],10) – 1)).content(“Rectangle Path 1”).position+[0,100]

    So there isn’t any other way to get a Shape Group Index other than extracting it from the Shape Group name string?

    Thanks!

  • Dan Ebberts

    September 9, 2016 at 3:43 pm

    The 3 takes you up 3 property group levels from the target property (the property with the expression, in this case). Note that (especially with shape layers) not all levels are necessarily visible in the UI. You can use propertyIndex to get a property or property group’s index within its parent group.

    Dan

  • Ranveer Singh

    January 15, 2020 at 12:35 pm

    Hey man,

    I know its been 7 year just in case you still don’t know how to do this or if someone is in need of it (like me) here is the solution.

    All you have to do is to replace the “Group 1” with “thisProperty.propertyGroup(1).propertyGroup(1).propertyIndex+1”

    If you want to understand how it works her is the link: https://youtu.be/xgUNncvKXY8

    content(thisProperty.propertyGroup(1).propertyGroup(1).propertyIndex+1).content("Rectangle Path 1").position+[0,100]

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

Page 1 of 3

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