Layer property functions (PB only)Using layer property functions, you can obtain values of specified properties or create keyframes, depending on how the properties and keyframes are used in an assignment. A layer property function uses the following format: function () The function acts on variables inside the parentheses and then returns a value. For example, the function value (layer, property) obtains a value for the specified property in the specified layer at the currently sampled frame. Motion Math includes three different types of layer property functions: Functions that obtain only values Functions such as time () or comp_audio_amplitude () can be used only on the right side of an assignment. In the following example, the current time is assigned to the variable T1: T1 = time (); Functions that can either obtain a value or create a keyframe Three functions obtain values or create keyframes, depending on which side of an assignment they are placed on: value() velocity() effect_value() When used on the right side of an assignment, the functions obtain values of specified properties and channels in a specified layer. In the following example, the current value of the Position property in the layer called square1 is multiplied by 1.5, and the result is assigned to the variable V1: V1 = value (square1, position) * 1.5; When used on the left side of an assignment, the functions create or modify keyframes. In the following example, a rotation keyframe with a value of 60 is created for the layer called arrow1: value (arrow1, rotation) = 60; Functions that obtain a value from the menus Three functions obtain values from the Layer, Property, and Channel menus: pop_layer() pop_property() pop_channel() These functions can be used on either side of an assignment. In the following example, the name of the layer selected in the second Layer menu is assigned to the variable L2. L2 = pop_layer (2); If menu functions are used on the left side of an assignment, they must be inside another function. In other words, you cannot assign a value directly to a menu function. In the following example, the Scale property in the layer specified by the pop_layer function is assigned the value of 10: value (pop_layer (1), scale) = 10; Using these menu functions makes it easy for other users to run the script by selecting layers, properties, and channels from the menus. For more information on these functions, see Using the Layer, Property, and Channel menus (PB only). |