I am trying to make an exporter, to copy all the particle data to a txt file, for further student work.I use it as a batch script, maybe I should use it as an event Script.
Code: Select all
file = open("C:/Users/Gabor/scenes/test/particles_version02/001.txt", "w")
emitter_export = scene.getEmitter("Circle01")
particle = emitter_export.getFirstParticle()
while particle:
id = particle.getId()
position = particle.getPosition()
velocity = particle.getVelocity()
density = particle.getDensity()
pressure = particle.getPressure()
file.write("%s %s %s %s %s %s %s %s %s" % (id,position.getX(),position.getY(),position.getZ(),velocity.getX(),velocity.getY(),velocity.getZ(),density,pressure))
particle = particle.getNextParticle()
Also afterwards I don't see any other particle ID just the first one. Maybe I misunderstand the code entirely, but I want a code like this:
Code: Select all
VARIABLES = "id" "x" "y" "z" "vx" "vy" "vz" "density" "pressure"
ZONE F=POINT, STRANDID=1, SOLUTIONTIME=0.03
109616 0.786 -0.185 0.063 0.033 0.006 0.032 1049.749 304.752
109615 0.786 -0.177 0.063 0.001 0.005 0.003 1035.493 176.532
109614 0.786 -0.158 0.061 -0.005 -0.006 -0.007 1013.543 -1.258
Code: Select all
# Iterate the list of particles and write out their ids.
currentParticle = emitter.getFirstParticle()
while currentParticle:
scene.message( str( currentParticle.id ) )
currentParticle = currentParticle.getNextParticle()
Please help me how to solve this.