bhMassAssets


bhMassAssets is a tool to package multiple non-deforming assets into one file. This file can then be referenced into the shot as a library. A second part of this tool is an interface for this library to copy (instance) the objects contained, to populate the shot.

The first part is making the library. This is as easy as selecting the models that you want in them that should be previously exported to FBX. The script loads the models into the scene, prefixes all objects with the concatenated filename and groups them under a common gizmo. It also assignes a lambert to all the objects and assigns a texture to the color channel. The snippet of code can ofcourse be adjusted to whatever naming convention has been used for textures in relationship to the objects and create completely different shader setups. Or if the script already detects a shader in the scene for that object, it won`t generate another shader, but assign that one instead.
Now that the tool has collected the models and assembled the library, you can still make adjustments. Most of the time that will not be necessary, but you can test and adjust the shaders or rename objects.
For renaming there is a utility at the top of the interface. "Concatenate name" removes all the underscores from a name and starts every section with a capital. With the text-field and token you can change specific parts of the name. In the text-field you enter then new string for the token you want to replace (a token is a part separated by underscores). The token-slider you set to the part you want to replace (counting from 1). If you set the token to `0` it will add the string to the end of the name. `-1` will prefix the names with the string. This renaming works on multi-selections.
So when the library is complete there is one more step to be done. That is to select the controller and click the "write dupliFile" button. This compiles a MEL-script that speeds up the actual duplication of the objects later on.



Using the library is just as straight-forward. Just reference the file into the shot and launch the interface. Because the tool uses instances, the original objects need to have their visibility attribute set to 1. This can be done by setting the "show all" attribute on the original object to 1. But this creates some clutter in the scene. This is easily solved by grouping that object under an empty transform and hiding that one instead.

Now that everything is setup, you can start duplicating. You need to have a transform selected in order to duplicate. This is because the newly created object will be placed at the same position as your selection, so you don`t have to look for it at the origin.
Click a button and the corresponding object will be instanced as a whole. It is advised to leave it like this untill the library has been finalised and no more changes will be made to the models. Because the group is instanced, and not the objects within, Maya doesn`t care what the contents of that group are. As such, changes can be made to the original referenced file and these will be propagated within the shot (with the exception of deleting objects from the library).
The downside of instancing the group as a whole is that you cannot make individual changes to the object, like moving or deleting a branch from a tree. What you can then do is unfold the instance. After this, instead of having the entire object as an instance, you have all the separate sub-objects as instances. So now you can move the branch of one instance without it affecting the others. Please note that this only works on translations, deformations still propagate to all the instances.