1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Windows Help: 3ds Max Particle Flow Spline Script

Discussion in 'Software' started by dullonien, 1 Feb 2013.

  1. dullonien

    dullonien Master of the unfinished.

    Joined:
    22 Dec 2005
    Posts:
    1,282
    Likes Received:
    29
    Using this guide for creating splines that follow the trajectories of a particle flow system in 3ds Max, I have been trying to do so to the system that I produced this render from:

    [​IMG]

    I can get the script to work with simple systems such as the one in the tutorial, but as soon as I introduce a 'Collision Spawn' event in my particle system the script throws the following error: '--No ""addKnot"" function for undefined', and points to line 67 in the script:
    Code:
    addKnot ParticleSplineShp 1 #smooth #curve pf.particlePosition
    The full script:
    Code:
    pf = $
        i2 = 1
        pTest = false
        endOfPFAnimation = 33
        endFrame = 33
        fIncrmnt = 2
    
           sliderTime = endOfPFAnimation
        while not pTest do 
        (
            pf.particleIndex = i2
            if pf.particlePosition == [0,0,0] then 
            (
                pTest = true
                global numParts = i2 - 1
            )
            i2 += 1
        )
        
        for i in 1 to numParts do 
        (
            newShp = splineShape()
            addNewSpline newShp
            newShp.name = ("ParticleSpline_" + i as string)
            
            newShp.thickness=0.01
            newShp.displayRenderSettings=true
            newShp.renderable=true
            newShp.displayRenderMesh=true
            newShp.adaptive=true
        )
        for t in 0 to (endFrame/fIncrmnt) do 
        (
            sliderTime = (t * fIncrmnt)
            for i in 1 to numParts do 
            (
                pf.particleIndex = i
                pId = pf.particleID
                if pId != 0 then 
                (
                    ParticleSplineShp = execute ("$ParticleSpline_" + pId as string)
                    addKnot ParticleSplineShp 1 #smooth #curve pf.particlePosition
                )
            )
        )
        
        select $'ParticleSpline_*'
        updateShape $
    I've tried producing a simple system where a single particle is sent to collide with a spherical deflector, at which point 10 new particles are spawned, and it still errors. With this simple particle system the flow looks like:
    Code:
    [B]PF Source 001[/B]
    Render 001 (Geometry) - turned off
          |
          v
    [B]Event 001[/B]
    Birth 001 (At 0 T:1)
    Position Object 001 (Box001)
    Speed 001 (Along Icon Arrow)
    Collision Spawn 001 (UOmniFlect001)
    Display 001 (Ticks)
    Anyone know why this error is occurring, and any possible solutions?

    This has been driving me round the bend for the last couple of days. Hopefully there's some people here who understand max scripts and can at least explain why what I'm trying to do is not possible so I can move on to trying to create a similar effect in a different way, avoiding collision spawn events.

    Update: Turning off 'delete parent' in the Collision Spawn options solves that error, but on my more complicated scene I'm now getting another error: '--Runtime error: updateShape: curve with insufficient knots, knots added: Editable Spline'.
     
    Last edited: 1 Feb 2013
  2. dullonien

    dullonien Master of the unfinished.

    Joined:
    22 Dec 2005
    Posts:
    1,282
    Likes Received:
    29
    After a lot of trial and error (and a lot of cursing), I managed to get the script working on my scene. I had to switch off one of the collision spawn events I had, as that was causing another Runtime error, but it still looks ok. Here's a quick low quality test render:

    [​IMG]
     

Share This Page