MAXScript

tyFlow Info

  • tyFlow_version(): returns the version number of the currently installed tyFlow DLO file.

  • tyFlow_found_in_scene(): returns information about the number of active tyFlow classes (objects, modifiers, etc) in the scene.

tyFlow License

  • tyFlow_activate_license(): attempts to activate a tyFlow PRO license (tyFlow.cfg must already exist and contain a valid license key or server address).

  • tyFlow_deactivate_license(): attempts to deactivates an activated tyFlow PRO license.

  • tyFlow_license_activated(): returns 1 if a tyFlow PRO license is currently activated, or 0 if not.

MAXScript Editor Access

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

  • [obj].editor_close(): closes the tyFlow editor GUI (if it is open).

  • [obj].editor_pan {x} {y}: pans the editor by the specified x/y values.

  • [obj].editor_resetPan(): resets the editor window pan value.

  • [obj].editor_zoom {zoom}: zooms the editor window by the specified value (negative values zoom out, positive values zoom in).

  • [obj].editor_resetZoom(): resets the editor window zoom value.

MAXScript Simulation

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

MAXScript Event/Operator Access

tyFlow events and operators can be created and manipulated using MAXScript.

Events

  • [obj].addEvent(): creates (and returns) a new event, centered in the tyFlow editor GUI.

  • [event].getEnabled() / [event].setEnabled {value}: gets or sets the enabled state of an event.

  • [event].getWidth() / [event].setWidth {value}: gets or sets the width of an event in the editor GUI.

  • [event].getName() / [event].setName {value}: gets or sets the name of an event.

  • [event].getPosition() / [event].setPosition {position}: gets or sets the position of an event in the editor GUI.

  • [event].addOperator {type} {where}: creates (and returns) a new operator in the event, of the specified type and at the specified 0-based position in the event’s operator list (use -1 for end-of-list position).

  • [event].remove(): removes the event from the flow.

Operators

  • [operator].getEnabled() / [operator].setEnabled {value}: gets or sets the enabled state of an operator.

  • [operator].getName() / [operator].setName {value}: gets or sets the name of an operator.

  • [operator].connect {event}: connects the operator to the specified event.

  • [operator].disconnect(): disconnects the operator from any event it is connected to.

  • [operator].remove(): removes the operator from its event.

Example

The following MAXScript example shows how to create events and operators, connect them together, modify their properties, etc:

(
	tf = tyflow()
	ev1 = tf.addEvent()
	ev1.setName "Birth"
	ev1.addOperator "Birth" -1
	snd = ev1.addOperator "Send Out" -1
	ev2 = tf.addEvent()
	ev2.setPosition (ev2.getPosition() + [230, 120])
	frc = ev2.addOperator "Force" -1
	frc.gravityStrength = -1
	snd.connect ev2
	ev2.addOperator "Display" -1
	tf.reset_simulation()
	tf.editor_open()
	tf.editor_pan -150 -50
)

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].getParticleMass {index}: returns the mass value for the specified particle index.

  • [obj].getAllParticleMasses(): returns an array of all paricle mass values 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].getParticleUVW {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]
)