pymel.core.effects.event

event(*args, **kwargs)

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.

Flags:
Long name (short name) Argument Types Properties
count (ct) int ../../../_images/query.gif ../../../_images/edit.gif
 
Collision number (for each particle) to which this event applies. Zero (the default) indicates that it applies to all collisions.
delete (d) bool ../../../_images/create.gif
 
Delete the specified event.
dieAtCollision (die) bool ../../../_images/query.gif ../../../_images/edit.gif
 
Particle dies at the collision specified by “count.” If no count value is given, die at first collision.
emit (em) int ../../../_images/query.gif ../../../_images/edit.gif
 

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.

idNumber (id) int  
   
list (ls) bool ../../../_images/create.gif
 

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.

name (n) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Assign a name to an event you are creating, or identify an event you wish to edit, query, or delete. See examples.
proc (pr) script ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

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 commandFlag can have multiple arguments, passed either as a tuple or a list.

random (r) bool ../../../_images/query.gif ../../../_images/edit.gif
 

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.

rename (re) unicode ../../../_images/query.gif
 
Assign a new name to an event you are editing. See examples.
select (s) bool  
 
This flag is obsolete. See the -name flag.
split (spl) int ../../../_images/query.gif ../../../_images/edit.gif
 

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.

spread (sp) float ../../../_images/query.gif ../../../_images/edit.gif
 

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) unicode ../../../_images/query.gif ../../../_images/edit.gif
 
Target object for emitting or split particles. New particles created through the -emit or -split flags join this object.

Derived from mel command maya.cmds.event

Example:

import pymel.core as pm

import maya.cmds as cmds

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

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

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

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

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

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

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

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

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

Previous topic

pymel.core.effects.emitter

Next topic

pymel.core.effects.expression

Core

Core Modules

Other Modules

This Page