You can add a custom attribute to a particle shape node and control its value in an expression.
To add a custom attribute:
Use the Hypergraph or Outliner to select the shape node.
The Add Attribute window appears:
Creates a vector attribute consisting of three floating point values.
Creates a floating point attribute.
Creates an integer attribute.
Creates an attribute consisting of an on/off toggle.
Creates a string attribute that accepts alphanumeric entries as data entry.
Creates an attribute that accepts selections from an “enumerated” or drop-down list.
Creates a per object attribute that you can set to a single value that applies to every particle in the object. A vector scalar is considered a single value with three numbers.
Creates a per particle attribute. You can set this type of attribute to different values for each particle.
Minimum and Maximum set the lowest and highest values you can enter for the attribute in the Attribute Editor or Channel Box. Default sets the default value displayed for the attribute. Because you’re going to control the attribute’s value with an expression, you might want to skip entering values for these options.
An expression isn’t bound by the Minimum and Maximum values. The attribute receives whatever value you assign it in the expression. The expression can read the attribute’s Default value or any other value you give it in the Attribute Editor or Channel Box.
When you select Scalar, you can’t create a counterpart initial state attribute by turning on Add Initial State Attribute.
You can’t set Minimum, Maximum, or Default values for an Array attribute.
The new attribute appears under the Extra Attributes section of the Attribute Editor. Although the attribute name is always spelled with an uppercase first letter in the Attribute Editor, you must use the exact spelling shown in the Expression Editor, whether lowercase or uppercase.
To assign values to a custom attribute
You can assign values to a custom attribute with the same techniques you use to assign values to static or dynamic attributes.
Suppose you’ve created a 10-particle object named sunspot, and you add to its particle shape node a float scalar (per object) attribute named glow. You assign the glow attribute a value in a creation expression as follows:
sunspotShape.glow = 11.5; print (sunspotShape.glow + "\n");
When you rewind the animation, the glow attribute of sunspotShape receives the value 11.5. The print statement displays the value in the Script Editor. The value appears 10 times because the expression executes once for each particle in the object.
Suppose you add a vector array (per particle) attribute named heat to the 10-particle sunspot shape node. You can give each particle a different value as in this creation expression:
float $randomNumber = rand(1); sunspotShape.heat = <<$randomNumber,0,0>>; print(sunspotShape.heat + "\n");
When you rewind the animation, the expression loops through 10 executions, once for each particle.
The first statement sets the $randomNumber variable to a random number between 0 and 1. The next statement assigns a vector to the heat attribute of a single particle. The left component of the vector assigned to heat is a different random number each time the statement executes. The middle and right components are always 0.
One particle might have the value <<0.57, 0, 0>>, another <<0.32, 0, 0>>, another <<0.98, 0, 0>>, and so on.
The print statement displays the values in the Script Editor.
If you add a custom vector attribute to an object, Maya displays the attribute in the Attribute Editor, but you can’t enter its value there. You must enter a value for it in an expression or with the Component Editor available from the Attribute Editor.