Ai User Data String

On May 21, 2015 by jw

Here is a simple MEL script that creates a texture path with a random file number as a shape attribute. Using the AiUserDataString, one aiStandard shader can assign random textures across multiple objects.

In this example, I have a folder on the desktop containing 61 icons. The script will loop through the selected objects and create a custom string attribute with a path to one of the icons in the folder. The AiUserDataString node is plugged into the file texture path on a standard Maya file node. When Arnold renders the scene, the texture call will look up the shape’s custom attribute to determine which texture to use. Here is more information on Arnold’s UserData nodes.


The shader setup:


Shape node custom attribute:


AiUserDataString “texture” attribute (this is case sensitive). It’s derived from the custom attribute like this: mtoa_constant_<variable>



Leave a Reply

Your email address will not be published. Required fields are marked *