Simulate Hair with Maya Batch
Ornatrix provides a few options for simulating hair. It is easy to perform the simulation inside Maya's viewports, but you may wish to instead opt for using Maya command line batch mode. For example, this is useful for automating simulation tasks for multiple scenes or to run complex simulations on a server away from workstations.
Simulating with Batch
To simulate hair this way we recommend using mayapy executable to run the Python script which will perform the simulation. You need to have your scene set up with a guides or hair shape which you want to simulate, a simulation operator like Moov Hair Physics or Dynamics, and an Animation Cache Operator above it. You will also need to know the names of these operator nodes. The following MEL command can then be executed on the Animation Cache Operator node to simulate and record the animated strand results to an Alembic file:
OxRecordAnimation animationCacheNode (flag: -startTime time) (flagEnd: -startTime time)
Example Script
For example, the following Python script will set up some guides and simulate them to an Alembic file from frame 0 to frame 5:
import pymel.core as pm
# Load Ornatrix if needed
if not pm.pluginInfo( "Ornatrix", query=True, loaded=True ):
pm.loadPlugin( "Ornatrix" )
guidesShape = # Load or create a new guides shape
moov = pm.PyNode( pm.mel.OxAddStrandOperator( guidesShape, "MoovPhysicsNode" ) )
animationCacheNode = pm.PyNode( pm.mel.OxAddStrandOperator( guidesShape, "AnimationCacheNode" ) )
# Record the animated guides to file
filePath = "resultAnimatedHair.abc"
animationCacheNode.filePath.set( filePath )
pm.mel.OxRecordAnimation( animationCacheNode, startTime = 0, endTime = 5 )