Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section

The following example will print the name of the simulator (node) , the current time (t) and the current time step (dt). The The if() statement is used to stop the simulation if the current frame is 2.

You can save the script below to a test.py file for Python or test.mel file for MEL and load it from Phoenix Simulator → Simulation → Scripting → Script File

 

for Python or test.mel file for MEL and load it from Phoenix Simulator → Simulation → Scripting → Script File

 

 

Column
width26%

PYTHON 3 (used for Maya 2022 and newer):

Code Block
import maya.cmds as cmds
import phxfd

def OnNewFrame(node, t, dt):
    print (node)
    print (t)
    print (dt)

    if( cmds.currentTime(query = True) == 2 ):
        phxfd.stop()
Column
width26%

PYTHON 2 (used for Maya 2021 and older)

Column
width40%

PYTHON:

Code Block
import maya.cmds as cmds
import phxfd

def OnNewFrame(node, t, dt):
    print node
    print t
    print dt

    if( cmds.currentTime(query = True) == 2 ):
        phxfd.stop()
Column
width40%26%

MEL:

Code Block
global proc OnNewFrame(string $node, float $t, float $dt) {
    print $node;
    print $t;
    print $dt;

    $now = `currentTime -q`;

    if($now == 2){
        phxfdSim -n $node -a "stop";
    }
}

...

Function Declaration

...

Example MEL function declaration:

...