### Lesson 6: thisComp

There are some useful terms to learn that we can use to get a great deal of information about a composition, as well as the elements inside the compostion. Please note that all of the examples are CASE SENSITIVE!!

thisComp.height

This returns the height of your comp in pixels. For example, for a NTSC D1 composition, thisComp.height would be equal to 486.

thisComp.width

This returns the width of your comp in pixels. For example, for a NTSC D1 composition, thisComp.width would be equal to 720.

thisComp.numLayers

This returns the number of layers in your current composition.

To demonstrate a simple example, let's consider the following expression as applies to Position:

x = value[0];

y = thisComp.height/(thisComp.numLayers/index);

[x,y]

Two-dimensional position is array, therefore it has two values: one for x and one for y. To have X position be freely editable in an expression, using 'value[0]' will leave the existing x position (position value number "0").

Next, we declare a calculation for Y. The value of the comp height divided by the number of layers in the comp divided by the index. Recall that 'index' is equal to the current number of the layer.

If we plug this expression into Position for just one layer (with only one layer in the comp), it will position the layer at the bottom of your composition. For example, 486 / (1 / 1) = 486.

However, if duplicates of this layer are made, each one will automatically distribute itself equally in Y.

Some other useful uses of this comp are as follows:

thisComp.duration

Returns the length of the comp in seconds.

thisComp.frameDuration

Returns the duration of one frame in time in seconds. 1/thisComp.frameDuration would return your current frame rate.

thisComp.height

This returns the height of your comp in pixels. For example, for a NTSC D1 composition, thisComp.height would be equal to 486.

thisComp.width

This returns the width of your comp in pixels. For example, for a NTSC D1 composition, thisComp.width would be equal to 720.

thisComp.numLayers

This returns the number of layers in your current composition.

To demonstrate a simple example, let's consider the following expression as applies to Position:

x = value[0];

y = thisComp.height/(thisComp.numLayers/index);

[x,y]

Two-dimensional position is array, therefore it has two values: one for x and one for y. To have X position be freely editable in an expression, using 'value[0]' will leave the existing x position (position value number "0").

Next, we declare a calculation for Y. The value of the comp height divided by the number of layers in the comp divided by the index. Recall that 'index' is equal to the current number of the layer.

If we plug this expression into Position for just one layer (with only one layer in the comp), it will position the layer at the bottom of your composition. For example, 486 / (1 / 1) = 486.

However, if duplicates of this layer are made, each one will automatically distribute itself equally in Y.

Some other useful uses of this comp are as follows:

thisComp.duration

Returns the length of the comp in seconds.

thisComp.frameDuration

Returns the duration of one frame in time in seconds. 1/thisComp.frameDuration would return your current frame rate.