MAXScript

MAXScript Editor Access

tyFlow objects have MAXScript interfaces which can be used to manipulate their editor windows.

  • [obj].editor_open(): opens the tyFlow editor GUI.

  • [obj].reset_simulation(): resets the tyFlow simulation and clears the cache.


MAXScript Particle Access

Both tyFlow and tyCache objects have MAXScript interfaces which can be used to read particle data.

Preparing particles

  • [obj].updateParticles {frame}: prepares particle data for MAXScript access at a particular frame.

The updateParticles function of a tyFlow or tyCache object MUST be called prior to accessing particle data.

  • [obj].numParticles(): returns the number of particles at the prepared frame.

Individual particle data

Data for individual particles can be accessed with their index. Valid particle indices (for tyFlow/tyCache objects with at least 1 particle) range from 1 to [obj].numParticles().

Particle indices are 1-based, not 0-based!

For optimized particle access, use the “getAllXXX” functions to receive an array filled with all particle data for a particular property. Getting and iterating that array will be much faster than repeated calls to the property access functions for each particle by their index.

  • [obj].getParticleID {index}: returns the unqiue ID for the specified particle index.

  • [obj].getAllParticleIDs(): returns an array of all particle IDs for the prepared frame.

  • [obj].getParticleAge {index}: returns the age (in frames) for the specified particle index.

  • [obj].getAllParticleAges(): returns an array of all particle ages (in frames) for the prepared frame.

  • [obj].getParticleTM {index}: returns the transform for the specified particle index.

  • [obj].getAllParticleTMs(): returns an array of all particle transforms for the prepared frame.

  • [obj].getParticlePosition {index}: returns the position for the specified particle index.

  • [obj].getAllParticlePositions(): returns an array of all particle positions for the prepared frame.

  • [obj].getParticleScale {index}: returns the scale for the specified particle index.

  • [obj].getAllParticleScales(): returns an array of all particle scales for the prepared frame.

  • [obj].getParticleVelocity {index}: returns the velocity (in units per frame) for the specified particle index.

  • [obj].getAllParticleVelocities(): returns an array of all particle velocities for the prepared frame.

  • [obj].getParticleShapeMesh {index}: returns the trimesh for the specified particle index.

  • [obj].getAllParticleShapeMeshes(): returns an array of all particle trimeshes for the prepared frame.

  • [obj].getParticleMatID {index}: returns the material ID override for the specified particle index.

  • [obj].getAllParticleMatIDs(): returns an array of all particle material ID overrides for the prepared frame.

A material ID override value of 0 means no override is assigned to the particle.

  • [obj].getParticleInstanceID {index}: returns the instance ID for the specified particle index.

  • [obj].getAllParticleInstanceIDs(): returns an array of all particle instance IDs for the prepared frame.

  • [obj].getParticleSimGroups {index}: returns the simulation group bitflags for the specified particle index.

  • [obj].getAllParticleSimGroups(): returns an array of all particle simulation group bitflags IDs for the prepared frame.

  • [obj].getParticleExportGroups {index}: returns the export group bitflags for the specified particle index.

  • [obj].getAllParticleExportGroups(): returns an array of all particle export group bitflags IDs for the prepared frame.

  • [obj].getParticleUVWChannels {index}: returns the mapping channel override indices for the specified particle index.

  • [obj].getAllParticleUVWChannels(): returns an array of all particle mapping channel override indices for the prepared frame.

  • [obj].getParticleUVWs {index | channel}: returns the mapping channel override value for the specified particle index.

  • [obj].getAllParticleUVWs {channel}: returns an array of all particle mapping channel override values for the prepared frame.

Here is an example script, showing how to access individual particle transforms at frame 15, for a tyFlow object named “tyFlow001”:

tf = $tyFlow001
tf.updateParticles 15
numParticles = tf.numParticles()
tms = tf.getAllParticleTMs()

for j in 1 to numParticles do
(
    tm = tms[j]
)