Notifications
Clear all

[Closed] Particle flow script hanging max 2011

Hi all,

I have a simple script that bakes particle positions to objects which works fine in max 2009 but hangs max in 2011 bot 32 and 64 bit…

It’s used in a script operator…

on ChannelsUsed pCont do
   (
   	pCont.usePosition = true
   	pCont.useSpeed = true
   	pCont.useSpin = true
   	pCont.useTM = true
   )
   
   on Init pCont do
   (
   	local pfSource = $PF Source 01' -- rename PF Source 01 to the name of the particle flow source object
       local pfEvent = pfSource.'Event 01' -- rename Event 01 to the name of the event you're baking from
       local birthGroupArray = pfEvent.Birth_Group_01.Particle_Objects --  rename Birth_Group_01 to the anem of the birth operator in the even you're baking from and spaces my be replaced with _
       global RENAME_ME_Array = for i = birthGroupArray.count to 1 by -1 collect birthGroupArray[i] -- rename RENAME_ME_Array to a unique name for each event
   )
   
   on Proceed pCont do 
   (
       local count = pCont.NumParticles() -- get the total number of particles in the event
       local integrationStepLength = (pCont.GetTimeEnd() - pCont.GetTimeStart()) as float -- get the integration step
       
       for i in 1 to count do -- loop through all the particles in the event
       (
           pCont.particleIndex = i -- set the index
           
           if currentTime > 0 then -- make sure we don't overwrite the object transform for frame 0 so that we have a safe frame incase something goes wrong
           (
               with animate on
               (
                   local newSpin = pCont.particleSpin -- get a copy of the particle spin at the start of the frame
                   newSpin.angle *= integrationStepLength -- multiply with the integration step to get the particle rotation at the end of the frame
                   
                   local spinMatrix = newSpin as matrix3
                   
                   local oldTM = pCont.particleTM
                   oldTM.row4 = [0, 0, 0]
                   
                   local newTM = oldTM * spinMatrix
                   
                   newTM.row4 = (pCont.particlePosition + integrationStepLength * pCont.particleSpeed) --  calculate the position at the end of the frame
                   
                   RENAME_ME_Array[i].transform = newTM -- make sure you replace RENAME_ME_Array with the unique name above
               )
           )
       )
   )
   
   on Release pCont do 
   (
       
   )

The problem line appears to be…

RENAME_ME_Array[i].transform = newTM -- make sure you replace  RENAME_ME_Array with the unique name above

If I comment that out and run in max 2011, everything is ok though obviously the objects are not baked so I’m guessing that something has changed between versions. Does anyone have any clue whats wrong?

Cheers,

Paul

1 Reply

On further investigation, I can print properties from RENAME_ME_Array[i] e.g…

print RENAME_ME_Array[i].transform
  print RENAME_ME_Array[i].pos

But I cannot set properties without it hanging e.g…

RENAME_ME_Array[i].pos = [0,0,0]

I’m stumped