Shape Layers Question

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
WindUpToy
Posts: 1
Joined: May 14th, 2011, 8:23 pm

I'm new to scripting for AE (but not new to programming) and I think I have discovered a bug in After Effects, or maybe I am just too ignorant to understand my problem. Please point me in the right direction.

In my script I have called the following:

Code: Select all

app.project.activeItem.selectedLayers[0].width
where the selected layer is a shape layer. It always returns "1920" (the comp width), not the actual width of the shape. I've tested this with other types of layers, and they all return their correct widths.
How do I get the correct width of the shape layer, or better yet the size of rectangles and the radii of ellipses?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

You need the sourceRectAtTime method. This is from the CS3 scripting guide:

AVLayer sourceRectAtTime() method
app.project.item(index).layer(index).sourceRectAtTime(timeT, extents)

Retrieves the rectangle bounds of the layer at the specified time index, corrected for text or shape layer content. Use, for example, to write text that is properly aligned to the baseline.

timeT: The time index, in seconds. A floating-point value.
extents: True to include the extents, false otherwise. Extents apply to shape layers, increasing the size of the layer bounds as necessary.

Returns a JavaScript object with four attributes, [top, left, width, height].
Post Reply