

I think this will do everything you want to do. Then it just offsets each layer by the value you set with the slider. The Z slider does nothing until you make the Shape Layers 3D. As you adjust the X and Y slider until the value for either is 100%, the layers will be perfectly lined up edge to edge. When the sliders are set to zero, the layers will stack on top of each other. The X and Y offset sliders work on a percentage of the current layer's height and width. YOfst = yAdj * refBox.height/2 + yAdj * lyrBox.height/2 XOfst = refBox.width/2 * xAdj + lyrBox.width/2 * xAdj ZAdj = thisComp.layer("Control").effect("Z Offset")("Slider") YAdj = thisComp.layer("Control").effect("Y Offset")("Slider")/100 XAdj = thisComp.layer("Control").effect("X Offset")("Slider")/100 If you start the Position expression with an if statement that checks the layer name and uses the default value for position when the layer name is Top or makes some calculations if the layer name is not Top, you can add this expression to the Shape Layer/Transform/Position property. I used a solid that can be placed above or below the stack of shape layers. The next step is to add some Controls/Sliders for X, Y, and Z offset. When you apply that expression to a shape layer, unless the Anchor Point is already in the center of the graphic, the layer position will change. The property could be Contents/Rectangle 1/Transform Rectangle 1/Anchor Point or Contents/Shape 1/Transform Shape 1/Anchor Point. This expression is added to Contents/Shape/Transform Shape/Anchor point: b = sourceRectAtTime() Shape layers have a Shape/Transform Shape property. If you are going to stack layers based on their size, the first thing you have to do is fix any Anchor Point problems. A controller layer is needed, and, to prevent expression errors, the top layer in the stack must be named Top, but that's easy.

I took a few minutes and created a couple of expressions and 3 Sliders that will stack and offset a bunch of other shape layers. There is no need to fiddle with toComp or toWorld to build an effective layer-stacking expression. It just offsets each layer in X by a portion of the width and offsets the layer in Y based on the slider. Your first expression does not move the layer's x value based on the layer index. All you need to create a cumulative offset is to multiply the offset distance by the layer index.

There is no need for sourceRectAtTime() if you are only offsetting the position unless you want to base the offset on the size of the layer. ZOfst = ctrl.effect("z, ofst")("Slider") * ref.index YOfst = ctrl.effect("y ofst")("Slider") * ref.index XOfst = ctrl.effect("x ofst")("Slider") * ref.index 3 sliders instead of one, multiplied by the index of the layer. Here is a more useful 3D layer stacking option. The expression offsets each layer in X, Y, and Z. After applying this expression, instead of being position z=0, it comes out z=2665.7Īny thoughts to simply make the first expression with 3D layers would be a massive help. For example it’s a 1920x1080 composition. Instead of aligning with the layer above, the position changes on the X and Z axis and I’m not sure why. The first layer works as intended but then every other layer doesn’t offset, and they just pile in on the same position.Ģ. Z = thisComp.layer(index - 1).position ġ. S = thisComp.layer("Control").effect("Spacing")("Slider") I came up with this Ī = thisComp.layer(index - 1).sourceRectAtTime()
#AFTER EFFECTS EXPRESSIONS THISCOMP UPDATE#
So I’ve been trying to update it, so it has the exact same function but works for 3D layers. I’ve been using this expression successfully, but fails when the layers are 3D: Regardless of the size or shape of the layer above it. Then each new layer below Layer 1 should be N pixels down on the Y axis. I’m trying to create a column of 3d layers.
