...
So, first of all it is necessary to create an attribute for an emitter which will then be applied to a particle:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# Write this part to SimulationPre emitter = scene.getEmitter("Circle01") emitter.createParticlesAttribute(100, PARTICLE_ATTR_TYPE_DOUBLE) emitter.createParticlesAttribute(101, PARTICLE_ATTR_TYPE_INT) emitter.createParticlesAttribute(102, PARTICLE_ATTR_TYPE_BOOL) emitter.createParticlesAttribute(103, PARTICLE_ATTR_TYPE_VECTOR) # Write this part to FramePre emitter = scene.get_PB_Emitter("Circle01") particleList = emitter.getParticles() for particle in particleList: particle.setAttribute(100, 3.14159) particle.setAttribute(101, 5) particle.setAttribute(102, True) particle.setAttribute(103, Vector.new(1.0,0.0,1.0)) |
...
To request an attribute, simply use the following construction:
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
for particle in particleList: pi = particle.getAttribute(100) scene.message(str(pi)) |
...
You can also remove an emitter’s ability to carry attributes with a destructor. Please note that this is not possible for single particles, but for certain attributes:
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
frame = scene.getCurrentFrame() if (frame == 50): emitter.destroyParticlesAttribute(102) |
...