ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Roland R. Kahlenberg
How to use Shape Group #s instead of layer index in an Expression
on Oct 31, 2013 at 12:00:13 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


Return to posts index

Dan Ebberts
Re: How to use Shape Group #s instead of layer index in an Expression
on Oct 31, 2013 at 7:55:46 pm

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

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


Dan



Return to posts index

Paul Roper
Re: How to use Shape Group #s instead of layer index in an Expression
on Nov 6, 2013 at 1:11:13 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 = <i><b>thisGroup</i></b>-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


Return to posts index


Dan Ebberts
Re: How to use Shape Group #s instead of layer index in an Expression
on Nov 6, 2013 at 3:45:20 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



Return to posts index

Paul Roper
Re: How to use Shape Group #s instead of layer index in an Expression
on Nov 7, 2013 at 10:14:00 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


Return to posts index

Dan Ebberts
Re: How to use Shape Group #s instead of layer index in an Expression
on Nov 7, 2013 at 5:14:28 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



Return to posts index


Paul Roper
Re: How to use Shape Group #s instead of layer index in an Expression
on Nov 7, 2013 at 5:47:39 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.


Return to posts index

Roland R. Kahlenberg
Re: How to use Shape Group #s instead of layer index in an Expression
on Nov 8, 2013 at 11:58:27 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


Return to posts index

Vincent Landrieu
Re: How to use Shape Group #s instead of layer index in an Expression
on Sep 9, 2016 at 9:34:12 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!


Return to posts index


Dan Ebberts
Re: How to use Shape Group #s instead of layer index in an Expression
on Sep 9, 2016 at 3:43:15 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



Return to posts index

Ranveer Singh
Re: How to use Shape Group #s instead of layer index in an Expression
on Jan 15, 2020 at 12:35:46 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:





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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]