numParticles() returns inaccurate result
#1
Hello, I'm new to tyflow. I've read the docs (https://docs.tyflow.com/tyflow_maxscript/) and trying to use maxscript to get particle data.

But when I call $.numParticles(), it won't return a valid result even when I enabled interface. Confused

Please help me, thank you!

My scene setup is in the image.

[Image: attachment.php?aid=3472]


Attached Files Thumbnail(s)
   
  Reply
#2
Did you call updateParticles first?
  Reply
#3
(05-10-2024, 02:38 AM)tyFlow Wrote: Did you call updateParticles first?

Yes, I did call updateParticles first. As in the post image, the first line is  $.updateParticles 15. [Image: attachment.php?aid=3472]

I also tried to write those code into a ms script. The result is also the same.

By the way, I can get Id from getAllParticleIDs(), when I have 169 particles, the array is properly filled with (1, 2, 3, ..., 169). But getParticleAge always returns 0, getParticlePosition returns (0, 0, 0) no matter what frame number I gave to updateParticles() function.

I attached my max scene and script run result.


.max   UE4_Max_VAT_Test011.max (Size: 912 KB / Downloads: 64)

here's my test code:

Code:
macroScript TestTools_TyflowTest category:"Test Tools" buttontext:"Test Tools" tooltip:"Test Tools"
(
    fn TestRead = (
       
        local tf = $tyFlow002
        --local tfSpline = $tfSplines001
        tf.updateParticles 15 -- update before read
        local numParticles = tf.numParticles()
        -- local tms = tf.getAllParticleTMs()

        -- show tf -- properties
        -- showinterfaces tf -- methods

        -- numParticles = 1

        format "TestRead: tf: %, numPartciels: %\n" tf numParticles
        format "Class tf %\n" (superClassOf tf) -- GeometryClass
        --format "Class tfSpline %\n" (superClassOf tfSpline) -- tfSpline Value
       

        --for j in 1 to numParticles do
        --(
            --local tm = tms[j]
        --)
        local ids = tf.getAllParticleIDs()
        format "tf id array: %\n" ids
        for id in ids do
        (
            format "processing particle id: %\n" id
            local age = tf.getParticleAge(id)
            local pos = tf.getParticlePosition(id)
            format "age: %; pos: %\n" age pos
        )
       
    )
    TestRead()
)
macros.run "Test Tools" "TestTools_TyflowTest"

the result is

[Image: attachment.php?aid=3476]


Attached Files Thumbnail(s)
   
  Reply
#4
I opened your file, ran the script, and received the correct result. Is there anything else I need to do to reproduce the issue you're seeing? What version of Max are you using?

Attached is the result I see when running your script.


Attached Files Thumbnail(s)
   
  Reply
#5
(05-13-2024, 06:27 PM)tyFlow Wrote: I opened your file, ran the script, and received the correct result. Is there anything else I need to do to reproduce the issue you're seeing? What version of Max are you using?

Attached is the result I see when running your script.

Thank you for your reply! I was using Max 2021, maybe this is  version specific issue? I'll try another max version.
  Reply
#6
Thanks, I can reproduce the issue in Max 2021 and will look further into what's causing it.

Edit: so I stepped through my code in Max 2021 and it's returning all the expected/proper values, but for whatever reason they're not being received by MAXScript properly...not idea why, to be honest. I would recommend trying the setup in a newer version of Max for now.
  Reply
#7
(05-14-2024, 01:14 PM)tyFlow Wrote: Thanks, I can reproduce the issue in Max 2021 and will look further into what's causing it.

Edit: so I stepped through my code in Max 2021 and it's returning all the expected/proper values, but for whatever reason they're not being received by MAXScript properly...not idea why, to be honest. I would recommend trying the setup in a newer version of Max for now.

Thank you for confirming the issue! I will use a newer version  Big Grin

Edit: 2024 works fine, thank you!

[Image: attachment.php?aid=3484]


Attached Files Thumbnail(s)
   
  Reply


Forum Jump: