What change python script in 2012

Discussions about the use of Realflow 2012
spiqy
Posts: 1
Joined: Fri Sep 21, 2012 10:00 am

What change python script in 2012

Postby spiqy » Sat Mar 22, 2014 1:36 pm

Firstly I think this post may belong here since it has to do with RF 2012 scripting issue. If not I apologize. I hope someone here can point me to a good direction. I have been looking around but cannot get a good result or any for that matter. I downloaded the beer foam script from resource and also from other places. These scripts as, I believe, were written in an older version of RF. When I load this my RF just hang and crash. I wanted to know what changes in the python language for RF? So far "getEmitter" has changed to "get_PB_Emitter" and even after I changed this nothing works. I have decrease my substep, scene scale, resolution etc I followed all the directions but I cannot make this work. Please if anyone can tell me what I may have done wrong let me know. Apart from the beer foam script that I downloaded I used this one

threshold = 2.5
water = scene.get_PB_Emitter("water")
foam = scene.get_PB_Emitter("foam")
particle = water.getFirstParticle()
while(particle) :
vel = particle.getVelocity()
vel_mag = vel.module()
pos = particle.getPosition()
id = particle.getId()
if (vel_mag>threshold) :

foam.addParticle(pos,vel)
water.removeParticle(id)
particle = particle.getNextParticle()

So far no luck. It hangs and then crash.


User avatar
Otuama
Posts: 1155
Joined: Fri Apr 02, 2010 12:56 am
Location: Swansea
Contact:

Re: What change python script in 2012

Postby Otuama » Sat Mar 22, 2014 10:02 pm

Are you using the correct formatting?

Code: Select all

threshold = 2.5
water = scene.get_PB_Emitter("water")
foam = scene.get_PB_Emitter("foam")
particle = water.getFirstParticle()
while(particle) :
   vel = particle.getVelocity()
   vel_mag = vel.module()
   pos = particle.getPosition()
   id = particle.getId()
   if (vel_mag > threshold) :

      foam.addParticle(pos,vel)
      water.removeParticle(id)
   particle = particle.getNextParticle()



I often find adding a new line at the end of the code make it work.
iCreate Ltd
'Strength does not come from physical capacity. It comes from an indomitable will.' - Gandhi
'What Does Success Look Like?' - iCreate Ltd


Return to “Realflow 2012”

Who is online

Users browsing this forum: No registered users and 1 guest