RSS< Twitter< etc

Stoke MX MAXScript Exposure

Last Edited on December 11, 2013

All Stoke MX properties and methods are exposed to MAXScript. In fact, the complete User Interface and Simulation logic are controlled by MAXScript.


The Stoke MAXScript exposure is subject to change without notice. The following documentation reflects the current implementation of the Stoke MAXScript Interfaces. Thinkbox Software reserves the right to modify the implementation and the documentation in the future as needed without guarantee for compatibility with existing scripts.

Components Overview


StokeBase GeometryClass object 

  • The StokeMX.DLO plugin implements a StokeBase Geometry Class 3ds Max object which has no UI.
  • The StokeBase implements the viewport playback and memory caching, Krakatoa Modifiers (Magma, Delete) support and drawing options (Dots, Vectors).
  • The StokeBase object is then extended by a Stoke Geometry Scripted Plugin which implements ParamBlocks to store the majority of simulation-related properties and objects. 

ReflowGlobal Interface 

  • The StokeMX.DLO also exposes a global interface called ReflowGlobal.
  • This interface provides properties and methods controlling the Simulation engine.
  • Evaluating showInterface ReflowGlobal in the MAXScript Listener will produce the following output:
showInterface ReflowGlobal
  Interface: ReflowGlobal
    .HomeDirectory : TSTR by value : Read
    .Version : TSTR by value : Read
    .Licensed : bool : Read
    .LoggingLevel : enum : Read|Write
       LoggingLevel enums: {#none|#error|#warning|#progress|#stats|#debug}
    CreateAdvector Type
    CreateReflowField Node
    CreateParticleVelocityField Node Spacing Min: Max: BoundsPadding: RemoveDivergence:
       Min default value: [0,0,0]
       Max default value: [0,0,0]
       BoundsPadding default value: 5
       RemoveDivergence default value: true
    CreateAdditiveVelocityField Fields
    CreateKrakatoaGenerator Node JitterRadius: IgnoreIDs:
       JitterRadius default value: 0.0
       IgnoreIDs default value: false
    CreateGeometryGenerator Node Mode: VolumeSpacing: SelectionType: VertexJitterRadius:
       Mode default value: "Surface"
       VolumeSpacing default value: 10.0
       SelectionType default value: "FaceSelection"
       VertexJitterRadius default value: 0.0
    CreateFumeFXGenerator Node
    CreateParticleSet ExtraChannels
    AdvectParticleSet ParticleSet Advector VelocityField TimeStepSeconds
    WriteParticleSet ParticleSet FilePath
    BeginRenderMode NodeList
    EndRenderMode NodeList
    GetSourceType Node
       GetSourceType enums: {#invalid|#particles|#geometry|#fumefx
    SetTempDirectory Directory

The properties and methods of this Interface are documented further on this page. 


  • The StokeUI.MS implements the Stoke Scripted Plugin extending the StokeBase class.
  • It also implements to UI-side simulation logic including the SIMULATE, STOP and RESUME buttons' event handlers and the callback functions called by the Simulator to update data and the UI.
  • Finally, it implements the MacroScript used to create Stoke objects via a toolbar or menu ActionItem. This MacroScript speeds up access to the Stoke object and also supports faster creation by adding selected objects to the Stoke Distribution and Velocity Field lists. 


  • The StokeSimulator.MS implements a StokeSimulator MAXScript Struct encapsulating the Simulator logic and the main simulation loop.
  • This separation allows other scripted tools to perform simulations without residing inside the StokeUI.MS. For example, the StokePartitioning.MS script (see below) can perform simulations without the Stoke object being selected or active in the Command Panel. 


  • The StokePartitioning.MS script implements a scripted tool for saving multiple variations of the same Stoke object with varying Random Seeds.
  • It includes Deadline Partitioning submission support.

ReflowGlobal Interface Properties And Methods


  • This read-only property contains the Windows path where the StokeMX.DLO was loaded from, up two folders.
  • For example, if the DLO was located under C:\Program Files\Thinkbox\Stoke MX\3dsMax2013, the propery will point at C:\Program Files\Thinkbox\Stoke MX\
  • This property is used to locate other components like .MS scripts and icons during the loading process.
  • This read-only property contains a String with the Version Number of the Stoke MX build.
  • It is used mainly to display the version in the Help rollout.
  • This read-only property contains a boolean value which is True of a Stoke MX license could be obtained, and False if no Stoke license could be found.
  • This property lets you get and set the Logging Level of Stoke MX.
  • The Logging is currently performed by outputting to the Listener.
  • Possible values are:
    • #none
    • #error
    • #warning
    • #progress
    • #stats
    • #debug


  • This method will open the Stoke MX License Dialog.
<Interface>ReflowGlobal.CreateAdvector <string>Type
  • Calling this method will return an Advector interface.
  • The Type argument can be "RK2", "RK3" or "RK4", but the current StokeMX build is set to use "RK2" since it is the fastest and the results of the three Advectors are usually very similar.
  • The Advector Interface exposes one method - AdvectParticle. It can be used to advect a particle position with a given particle velocity using a velocity field within a specified time interval:
a = ReflowGlobal.CreateAdvector "RK2"
showInterface a
  Interface: Advector
    AdvectParticle ParticlePosition ParticleVelocity VelocityField TimeStepSeconds
  • Calling this method will return a new IDAllocator Interface.
  • This Interface should be assigned to the .IDAllocator property of Particle Generators. It is responsible for assigning IDs to new particles created by the Particle Generators.
  • The IDAllocator Interface exposes one method - AllocateIDs.
idSource = ReflowGlobal.CreateIDAllocator()
showInterface idSource
  Interface: IDAllocator
    <INT64>AllocateIDs <INT64>NumIDs
<Interface>ReflowGlobal.CreateReflowField <node>Node
  • Calling this method will return a new ReflowField Interface.
  • The argument must be a valid Velocity Field source, but NOT a particle system or other Stoke objects (which are handled by the CreateParticleVelocityField() method). 
  • Valid sources are Force SpaceWarps, FumeFX and SIM Ember grids.
  • The ReflowField Interface exposes one property - .VelocityScale which defines the Velocity Scale of the field and defaults to 1.0.
  • The ReflowField Interface exposes two methods - UpdateToTime() and EvaluateVelocity(). 
  • UpdateToTime() updates the source to the specified time in order to produce the velocity field at that time.
  • EvaluateVelocity() can be used to query the velocity of the field at a given point in space.
rf = ReflowGlobal.CreateReflowField $FumeFX001
showInterface rf
  Interface: ReflowField
    .VelocityScale : float : Read|Write
    <void>UpdateToTime <time>Time
    <point3 by value>EvaluateVelocity <point3>Position
<Interface>ReflowGlobal.CreateParticleVelocityField <node>Node <float>Spacing Min:<point3> Max:<point3> BoundsPadding:<integer> RemoveDivergence:<bool>
       Min default value: [0,0,0]
       Max default value: [0.195462,0,0]
       BoundsPadding default value: 5
       RemoveDivergence default value: true
  • Calling this method will return a new ReflowField Interface based on the Particle object passed as first argument.
  • The second argument defines the voxel grid size.
  • The optional arguments allow the definition of the min. and max. bounds of the grid, the padding of the grid beyond the automatically determined size, and the divergence removal.
<Interface>ReflowGlobal.CreateAdditiveVelocityField <Interface array>Fields
  • Calling this method will combine additively the ReflowField interfaces passed as array argument and will return a new ReflowField Interface with the resulting new velocity field.
<Interface>ReflowGlobal.CreateKrakatoaGenerator <node>Node JitterRadius:<float> IgnoreIDs:<bool>
       JitterRadius default value: 0.0
       IgnoreIDs default value: false
  • Calling this method will create a Particle Generator from a Particle source including Krakatoa PRT objects, Particle Flow, Thinking Particles or Legacy Particles, and will return a new ParticleGenerator Interface.
pg = ReflowGlobal.CreateKrakatoaGenerator $
showInterface pg
  Interface: ParticleGenerator
    .RandomSeed : integer : Read|Write
    .GeneratorRate : INT64 : Read|Write
    .DiffusionConstant : float : Read|Write
    .InitialVelocityField : Interface : Read|Write
    .IDAllocator : Interface : Read|Write
    .InitialLifespan : point2 by value : Read|Write
    .AvailableChannels : TSTR by value array : Read
    <void>UpdateToTime <time>Time
    <void>GenerateNextParticles <Interface>ParticleSet <float>TimeStepSeconds
<Interface>ReflowGlobal.CreateGeometryGenerator <node>Node Mode:<string> VolumeSpacing:<float> SelectionType:<string> VertexJitterRadius:<float>
       Mode default value: "Surface"
       VolumeSpacing default value: 10.0
       SelectionType default value: "FaceSelection"
       VertexJitterRadius default value: 0.0
  • Calling this method will create a new Particle Generator from the specified geometry mesh and return a ParticleGenerator Interface.
<Interface>ReflowGlobal.CreateFumeFXGenerator <node>Node
  • Calling this method will create a new Particle Generator from the specified FumeFX grid and return a ParticleGenerator Interface.
<Interface>ReflowGlobal.CreateParticleSet <string array>ExtraChannels
  • Creates a new empty particle set with the standard channels, plus the channels specified.
<void>ReflowGlobal.AdvectParticleSet <Interface>ParticleSet <Interface>Advector <Interface>VelocityField <float>TimeStepSeconds
  • Advects all particles in a particle set, using the specified advection scheme and velocity field.
  • ParticleSet: The ParticleSet Interface instance to advect.
  • Advector: The instance of the Advector Interface that implements the advection scheme.
  • VelocityField: The instance of the ReflowField Interface that implements the velocity field affecting the particles.
  • timeStepSeconds: The time (in seconds) that the particles are affected by the velocity field.
<void>ReflowGlobal.WriteParticleSet <Interface>ParticleSet <filename>FilePath
  • Saves a particle set to file.
  • ParticleSet: The IParticleSet instance to save to disk, cast as a FPInterface*.
  • FilePath: Path to file to save to disk
<void>ReflowGlobal.BeginRenderMode <node array>NodeList
  • Some 3ds Max objects have different viewport and render settings. This function (and its pair EndRenderMode) will set a collection of nodes and all of their dependencies to be in render mode.
  • NOTE: You MUST call EndRenderMode with the same node list to reverse the effects of this call. Failure to do so will cause undefined behavior.
  • nodes: The list of nodes to put into render mode. All of the dependecies of these nodes will also be put into render mode.
<void>ReflowGlobal.EndRenderMode <node array>NodeList
  • The pair of 'BeginRenderMode', which reverts the changes.
  • nodes: The list of nodes to exit render mode. This must be the same list as passed to 'BeginRenderMode'.
<enum>ReflowGlobal.GetSourceType <node>GetSourceType
       GetSourceType enums: {#invalid|#particles|#geometry|#fumefx}
  • Returns an enumeration describing the appropriate factory function from ReflowGlobal Interface to use when creating a particle generator from the specified source.
  • GetSourceType: The node to inspect.
<enum>ReflowGlobal.SetTempDirectory <filepath>Directory
  • Sets the temporary directory used when writing particle files to a network location.
  • When writing to non-local storage locations, a particle file is first written to the temp directory then moved to the target destination. For local drives, the temporary file is written directly to the destination folder.
  • The argument is the path to the temporary directory to use. If undefined, the default directory will be used.
  • This allows you to set a faster storage medium for temporary files (e.g. an SSD drive) instead of writing to the default temp. directory (typically on the C: drive).
  • Because the PRT saving process is currently CPU-bound due to the compression algorithm used, this has little to no effect on the performance at this point.