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 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

 

 

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 2020 and older):

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%

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:

...

 

MEL Functions

phxfdSystem [-q] [-node(-n) string] [ system  string]

Specify which coordinate system to be used when calling phxfdGetphxfdInject and phxfdParticle.

-q

query the current coordinate system.

-node

determine manually the simulator node.

system

the coordinate system to set:

"object" - Object space

"world" - World space

"grid","core" - Grid space

 

Return value:

none

phxfdInject [-node(-n) string] -position(-pos) float float float -discharge(-d) float [-temperature(-t) float] [-smoke(-sm) float] [-fuel(-fl) float] [-velocity(-vel) float float float] [-uvw float float float]

Inject fluid in a given point. Using this function you can create your own procedural sources. The result of the function CAN NOT be achieved by calling one or more phxfdSet functions, because they do not affect the quantity of the fluid, but only the parameters carried by the fluid. The injection of fluid in some point causes changes in the content only of the nearest 8 cells, but produces an outgoing flow in the entire grid. Nevertheless the function is not slower than the ordinary phfxSet function, because the outgoing flow appears later, when the simulation is executed. If phxfdGet function is executed immediately after phxfdInject in some near point, the velocity will be not changed.

-node

determine manually the simulator node.

-position

the position of the injection.

-discharge

the speed (not the quantity) of the discharged fluid.

-temperature

the temperature of the released fluid measured in K.

-smoke

the concentration of the "Smoke" channel.

-fuel

the concentration of the "Fuel" channel.

-velocity

the concentration of the "Velocity" channel.

-uvw

the concentration of the "UVW" channel.

Return value:

true if the operation was completed successfully, and false otherwise.

phxfdSet [-node(-n) string] -position(-pos) int int int [-temperature(-t) float] [-smoke(-sm) float] [-fuel(-fl) float] [-velocity(-vel) float float float] [-uvw float float float]

Directly set the content of a particular cell inside the grid. Note that this function works only in grid space and phxfdSystem do not have effect on it.

-node

determine manually the simulator node.

-position

the position of the cell.

-temperature

the temperature value in K.

-smoke

the value for the "Smoke" channel.

-fuel

the value for the "Fuel" channel.

-velocity

the value for the "Velocity" channel.

-uvw

the value for the "UVW" channel.

Return value:

true if the operation was completed successfully, and false otherwise.

phxfdGet [-node(-n) string] -position(-pos) float float float [-temperature(-t)] [-smoke(-sm)] [-fuel(-fl)] [-velocity(-vel)] [-uvw]

Get the content of the grid at a given point. Note that the point is in the coordinate system specified by phxfdSystem.

-node

determine manually the simulator node.

-position

the position of the content that must be accessed.

-temperature

get the temperature in K.

-smoke

get the value of the "Smoke" channel.

-fuel

get the value of the "Fuel" channel.

-velocity

get the value of the "Velocity" channel.

-uvw

get the value of the "UVW" channel.

Return value:

float[] An array of floats with the content of the grid at that point. The queued channels are return in a fixed order - temperature, smoke, fuel, velocity, uvw.

phxfdFreeze -position(-pos) int int int [ freeze  bool] [ source  bool]

Freeze a cell during the simulation. The cell can be made optionally a source.

-position

the position of the cell to freeze.

freeze

if 1, the cell will be frozen, if 0 - unfrozen, default 1.

source

if 1, the cell will be marked as a source, if 0 - unmarked, default 0.

Return value:

true if the operation was completed successfully, and false otherwise.

phxfdParticle [-node(-n) string] -position(-pos) float float float -partgroup(-pg) string [-velocity(-vel) float float float] [-radius(-rad) float]

Create particle in given position with given properties.

-node

determine manually the simulator node.

-position

the position of the new particle.

-partgroup

determine to which particle group to assign the new particle.

-velocity

set the initial velocity of the particle.

-radius

set the radius of the particle (only for foam and splashes).

Return value:

true if the operation was completed successfully, and false otherwise.

phxfdSaveCache  filename string  node string

Save the current content of the grid to an AUR or VDB cache file.

filename

the cache file name.

node

the simulator node name.

Return value:

true if the operation was completed successfully, and false otherwise.

 

 

Python Functions

setsystem  system  string [ node  string]

Specify which coordinate system to be used when calling getinject and particle.

Return value:

true if the operation was completed successfully, and false otherwise.

getsystem [ node  string]

Return the current coordinate system.

Return value:

string The current coordinate system.

inject (x float, y float z float) disch float [temp float] [smoke float] [(vx float, vy float, vz float)] [(ufloat, v float, w float)]

Inject fluid in given point. Using this function you can create your own procedural sources. The result of the function CAN NOT be achieved by calling one or more set functions, because they do not affect the quantity of the fluid, but only the parameters carried by the fluid. The injection of fluid in some point causes changes in the content only of the nearest 8 cells, but produces an outgoing flow in the entire grid. Nevertheless the function is not slower than the ordinary phfxSet function, because the outgoing flow appears later, when the simulation is executed. If get function is executed immediately after inject in some near point, the velocity will be not changed.

Return value:

true if the operation was completed successfully, and false otherwise.

set (cx int, cy int cz int) [temp float] [smoke float] [(vx float, vy float, vz float)] [(u float, v float, wfloat)] [ node  string]

Directly set the content of a particular cell inside the grid. Note that this function works only in grid space and setsystem do not have effect on it.

Return value:

true if the operation was completed successfully, and false otherwise.

setT (cx int, cy int cz int) temp float [ node  string]

Directly set the temperature in K of a particular cell inside the grid. Note that this function works only in grid space and setsystem do not have effect on it.

Return value:

true if the operation was completed successfully, and false otherwise.

setSm (cx int, cy int cz int) temp float [ node  string]

Directly set the value of the "Smoke" channel of a particular cell inside the grid. Note that this function works only in grid space and setsystem do not have effect on it.

Return value:

true if the operation was completed successfully, and false otherwise.

setFl (cx int, cy int cz int) temp float [ node  string]

Directly set the value of the "Fuel" channel of a particular cell inside the grid. Note that this function works only in grid space and setsystem do not have effect on it.

Return value:

true if the operation was completed successfully, and false otherwise.

setV (cx int, cy int cz int) temp float [ node  string]

Directly set the velocity of a particular cell inside the grid. Note that this function works only in grid space and setsystem do not have effect on it.

Return value:

true if the operation was completed successfully, and false otherwise.

setUVW (cx int, cy int cz int) temp float [ node  string]

Directly set the value of the "UVW" channel of a particular cell inside the grid. Note that this function works only in grid space and setsystem do not have effect on it.

Return value:

true if the operation was completed successfully, and false otherwise.

get (x float, y float z float) [ node  string]

Get the content of the grid at a given point. Note that the point is in the coordinate system specified by setsystem.

Return value:

[float float float tuple tuple] array with the content in this order - temperature, smoke, fuel, velocity, uvw.

getT (x float, y float z float) [ node  string]

Get the temperature in K of the grid at a given point. Note that the point is in the coordinate system specified by setsystem.

Return value:

float the temperature in K.

getSm (x float, y float z float) [ node  string]

Get the value of the "Smoke" channel at a given point. Note that the point is in the coordinate system specified by setsystem.

Return value:

float the smoke.

getFl (x float, y float z float) [ node  string]

Get the value of the "Fuel" channel at a given point. Note that the point is in the coordinate system specified by setsystem.

Return value:

float the fuel.

getV (x float, y float z float) [ node  string]

Get the velocity of the grid at a given point. Note that the point is in the coordinate system specified by setsystem.

Return value:

tuple the velocity.

getUVW (x float, y float z float) [ node  string]

Get the value of the "UVW" channel at a given point. Note that the point is in the coordinate system specified by setsystem.

Return value:

tuple the uvw.

freeze (cx int, cy int cz int) [ freeze  bool] [ source  bool]

Freeze/Unfreeze the cell at a given point during the simulation, and optionally mark it as a source.

Return value:

true if the operation was completed successfully, and false otherwise.

particle  group  string (x float, y float z float) [(vx float, vy float, vz float)] [ radius  float] [ node  string]

Create a particle in a given position with given properties.

Return value:

true if the operation was completed successfully, and false otherwise.

saveCache  filename  string [ node  string]

Save the current content of the grid to a cache file.

Return value:

true if the operation was completed successfully, and false otherwise.

...

mayabatch.exe -file "D:\PHOENIX_QA\batchSimScene.ma" -command "phxfdBatchSim(\"PhoenixFDSimulator1\")"


Option

...

Vars

...

Maya Option Vars

optionVar -sv "PhoenixFD_cachePath" string

Set the current cache path that will be used with the template path names.

optionVar -iv "PhoenixFD_safemode" number

Run Phoenix in safe mode. This will turn off the shading preview when loading new scenes to prevent display problems.