How to force MassFX simulation to finish before next line in MaxScript is executed

How to force MassFX simulation to finish before next line in MaxScript is executed

Anonymous
Not applicable
446 Views
2 Replies
Message 1 of 3

How to force MassFX simulation to finish before next line in MaxScript is executed

Anonymous
Not applicable

In 3ds MaxScript 2020 (run on Win 10) I have a loop

for i=1 to 50 do

(

-- do something A

PxRunSimulation()

-- do something B(i)

macros.run "PhysX" "PxResetSimMS"

)

Unfortunately, B is executed before simulation ends. How to prevent it? I mean, how to force B to wait until simul is finished? I tried this

         while PxIsSimulationRunning(true) do ( )

but Autodesk freezes. I'm 2 weeks beginner of 3ds so please be forgiving (=extra clear) in your answer. Thx

0 Likes
447 Views
2 Replies
Replies (2)
Message 2 of 3

istan
Advisor
Advisor
See Interface:nvpx
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thx Istan but I remain clueless (looked at Interface:nvpx->Simulation, found only a few functions which did not help me, or maybe I was using them incorrectly). I found another solution which is ugly (I’m afraid I won’t be able to run this script in a batch mode)

for i=1 to NN do

(

                -- do_something_A

                for k=1 to 100 do

                (

                                PxStepSimulation()

                )

                --do_something_B(i)

                macros.run "PhysX" "PxResetSimMS"

)

What I’m trying: fill a box (static) with NN copies of the same part (dynamic) dropped one by one. I’m interested in the final still distribution of parts (which I export to outside) not in live simulation per se.

Any idea for better solution ?

0 Likes