Dyverso Domains
Add the script to Simulation Flow > (Ctrl/Cmd + F2) > FramesPre or StepsPre.
Get all particles from "DY_Domain01" and delete them when their velocity is greater than 5.0 m/s.
Code Block | ||
---|---|---|
| ||
# Get the domain "DY_Domain01" and its particles dyversoDomain = scene.get_DY_Domain("DY_Domain01") dyversoParticles = dyversoDomain.getParticles() # Loop through every individual particle and delete it if its velocity is greater than 5.0 m/s for particle in dyversoParticles: if (particle.getVelocity().module() > 5.0): dyversoDomain.removeParticle(particle.getId()) |
Hybrido Domains
Add the script to Simulation Flow > (Ctrl/Cmd + F2) > FramesPre or StepsPre.
Most attributes of Hybrido core fluid particles are controlled by the solver and cannot be changed, but it is possible to trigger certain events, e.g. to increase the Hybrido emitter's "Speed" parameter dynamically:
Code Block | ||
---|---|---|
| ||
# Initialize the required values # Get the domain "HY_Domain01" and its particles, get the emitter "HY_Emitter01" # Read out the emitter's "Speed" parameter and the current number of particles hybridoDomain = scene.get_HY_GridDomain("HY_Domain01") hybridoEmitter = scene.get_HY_Emitter("HY_Emitter01") hybridoParticles = hybridoDomain.getParticles() emitterSpeed = hybridoEmitter.getParameter("@ Speed") numOfParticles = len(hybridoParticles) currentVelocity = 0.0 maxSpeed = 5.0 # Sum up all velocities for particle in hybridoParticles: currentVelocity += particle.getVelocity().module() # Calculate average velocity and avoid illegal division by zero: if (numOfParticles > 0): averageVelocity = currentVelocity / float(numOfParticles) # Check, if average velocity is greater than current emitter speed and smallerless than the given speed limit "maxSpeed" if (averageVelocity > emitterSpeed and averageVelocity <= maxSpeed): hybridoEmitter.setParameter("@ Speed", averageVelocity) |
...
Standard Particle Fluid Emitters
Add script to Simulation Flow (Ctrl/Cmd + F2) > FramesPre or StepsPre.
Get all particles from "Circle01" and delete them when their velocity is greater than 5.0 m/s.
"for ... in" Method
Code Block | ||
---|---|---|
| ||
# Get the standard particle emitter "Circle01" and its particles standardEmitter = scene.get_PB_Emitter("Circle01") standardParticles = standardEmitter.getParticles() # Loop through every individual particle and delete it if its velocity is greater than 5.0 m/s for particle in standardParticles: if (particle.getVelocity().module() >= 5.0): standardEmitter.removeParticle(particle.getId()) |
"while ... next" Method
Code Block | ||
---|---|---|
| ||
# Get the standard particle emitter "Circle01" and its first particle standardEmitter = scene.get_PB_Emitter("Circle01") particle = standardEmitter.getFirstParticle() |
...
# Loop through every individual particle and delete it if its velocity is greater than 5.0 m/s while (particle): if (particle.getVelocity().module() >= 5.0): standardEmitter.removeParticle(particle.getId()) |
...
# Get the emitter's next particle particle = particle.getNextParticle() |