Convert particles to SPLine by MaxScript

Convert particles to SPLine by MaxScript

 

————–Download Script————–

rollout lines_rollout "Particle to Line"
( 
local time_val = 0 
local particlearr=#() 
local particl_conections=#() 
fn particle_filt obj = classof obj == PF_Source 
pickbutton pick01 "Pick Particle" width:140 filter:particle_filt autoDisplay:true 
spinner sp01 "Thickness" range:[0.001,1000,0.05] 
spinner sp02 "Connections" range:[2,20,4] type:#integer 
Button create_btn "Create" width:140 
timer clock interval:10 active:false 
progressbar progress ""  
Button refresh "Refresh Viewport" width:140 
on refresh pressed do enableSceneRedraw() 
on create_btn pressed do 
( 
max_val = 0.05 
if(pick01.object  != undefined)then 
( 
particlearr=#() 
particl_conections=#()
 ---------   
pfsrc = pick01.object     
pfsrc.particleID = 1   
        while pfsrc.particlePosition != [0,0,0] do
              (
               append particlearr (pfsrc.particleTM.pos)
               pfsrc.particleID +=1
              )
 ------------
 time_val = 0
 clock.active =true
 disableSceneRedraw()
     )
   ) 

on clock tick  do 
(
    num = 1
    i = time_val + 1
     if( i <= particlearr.count)then
               (
                arr2=#()
            arr3=#()
             for j=1 to particlearr.count do
                (
            if( j != i )then
              (
           arr3[j] = distance particlearr[i]  particlearr[j]
           arr2[j] = distance particlearr[i]  particlearr[j]
              )else
               (
               arr3[j] = 1000000.0]
           arr2[j] = 1000000.0
               )
                 )
            sort arr2 val1 = sp02.value val2= sp01.value
             for ii=1 to val1 do 
            ( 
         for jj=1 to arr3.count do 
                (
          if (arr3[jj] == arr2[ii] ) then 
         (
  if(findItem particl_conections (i as string +"_"+jj as string) ==0)then  
(  
vnsp = splineShape()    
                      vnsp.render_renderable =true
  vnsp.displayRenderMesh  =true
  vnsp.render_sides = 4 
                         vnsp.render_thickness =val2
                          vnsp.name="vnsp"+num as string
  num +=1
          lin = addnewSpline vnsp
                        addKnot vnsp lin #corner #line particlearr[i] 
                       addKnot vnsp lin #corner #line particlearr[jj] --updateShape vnsp
      append particl_conections ((i as string +"_"+jj as string))
  append particl_conections ((jj as string +"_"+i as string))
  )
          )
                ) 
            )
   --deleteItem particlearr i
                progress.value = time_val*100.0/particlearr.count
        time_val +=1
                  )else (
 a =group ($vnsp*) 
select a 
clock.active =false
 progress.value =0
 enableSceneRedraw()
 ) --------------------------------------------- 
)
)
createdialog lines_rollout