Go to: Synopsis. Return value. Related. Flags. Python examples.

Synopsis

event( [object] , [count=uint], [delete=boolean], [dieAtCollision=boolean], [emit=uint], [list=boolean], [name=string], [proc=script], [random=boolean], [rename=string], [select=boolean], [split=uint], [spread=float], [target=string])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

event is undoable, queryable, and editable.

The event command assigns collision events to a particle object. Collision events are stored in multi-attributes in the particle shape. The event command returns the event name.

Return value

stringfor creation; string array for list.

In query mode, return type is based on queried flag.

Related

collision, particle

Flags

count, delete, dieAtCollision, emit, list, name, proc, random, rename, select, split, spread, target
Long name (short name) Argument types Properties
count(ct) uint queryedit
Collision number (for each particle) to which this event applies. Zero (the default) indicates that it applies to all collisions.
split(spl) uint queryedit
Colliding particle splits into specified number of new particles. These new particles become part of the assigned target object. If no target has been assigned, they become part of the same object. The new particles inherit the current age of the particle that split. They use the velocity inheritance parameter of the target object. If you set both emit and split, the event will do both: first emit new particles, then split the original one. This is a change from earlier versions where emit and split were mutually exclusive.
dieAtCollision(die) boolean queryedit
Particle dies at the collision specified by "count." If no count value is given, die at first collision.
emit(em) uint queryedit
Emit n additional particles into the assigned target object. The original (colliding) particle survives as well, and remains in its original object. The new particles have age zero and mass equal to the emitting particle. They use the velocity inheritance parameter of the target object.
random(r) boolean queryedit
Used with -split and -emit flags. If -random is set true and -split or -emit is set to n, then a random number of particles uniformly distributed between 1 and n will be created at the event.
spread(sp) float queryedit
Particles created at collision will spread out a random amount from the rebound direction of the colliding particle. The spread is specified as a fraction (0-1) of 90 degrees. If spread is set at 0 (the default) all the new particles created may coincide.
target(t) string queryedit
Target object for emitting or split particles. New particles created through the -emit or -split flags join this object.
delete(d) boolean create
Delete the specified event.
name(n) string createqueryedit
Assign a name to an event you are creating, or identify an event you wish to edit, query, or delete. See examples.
rename(re) string query
Assign a new name to an event you are editing. See examples.
list(ls) boolean create
List all events for the chosen shape, like this: event1Name event2Name ... If no shape identified, list all events for all shapes, like this: shape1Name event1Name shape2Name event2Name... Returns a string array.
select(s) boolean
This flag is obsolete. See the -name flag.
proc(pr) script createqueryedit
Specify a MEL proc to be called each time the event occurs. This must be a global proc with arguments as follows: global proc procName( string obj, int id, string objHit ); Arguments passed in are the name of the particle object, the id of the particle which collided, and the name of the object collided with. You can use particle -id -q to get values of the particle's attributes.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

cmds.event( em=2, t='newCloud' )
# At every collision, emit two new particles into the object
# newCloud. The original colliding particles will survive and
# remain in their original object. This event will be
# assigned to the currently selected object.

cmds.event( em=2 )
# At every collision, emit two new particles into the same object.

cmds.event( count=1, em=2 )
# At the first collision for each particle, emit two new particles
# into the same object.
# Subsequent collisions for that same particle will not cause any
# additional particles to be emitted. However, the new particles will
# each emit two new ones at their first collision, since they also
# belong to the object for which this event has been assigned.

cmds.event( die=1, count=2 )
# All particles in the selected object will die at their second
# collision.

cmds.event( 'myCloud', name='foo', count=1, q=1 )
# Return the current value of the count parameter for the event "foo"
# assigned to particle shape myCloud.  The order of the flags is
# important.  Thef lag you are querying (in this case, -count) must
# come before the -q.  The -name flag and the particle object name must
# come after.

cmds.event( 'myCloud', d=True, name='foo' )
# Delete the event "foo" assigned to particle shape myCloud.

cmds.event( 'myCloud', e=True, name='foo', emit=2 )
# Edit the "emit" value of the event "foo" assigned to
# particle shape myCloud.

cmds.event( 'myCloud', proc='myProc' )
# Call the MEL proc "myProc(name, id, name) each time a particle
# of myCloud collides with anything.

cmds.event( name='oldName', e=1, rename='newName' )
# For the selected particle shape, rename the event "oldName" to "newName."