fn tp_export_csv  tp  filename =
(
	ms     = tp.tp_mastersysteminterface
	range =  animationRange
		
	for f = range.start to range.end do
	(
		out_name = getFilenamePath filename + getFilenameFile filename + formattedPrint f + ".txt"
		
		out_file = openFile out_name mode:"w"
			
		if out_file != undefined then
		(	
			ms.updateparticles f
			
			tp.groupmanager.getparticles &pids true
			
			for p = 1 to  pids.count do
			(
				if ms.isalive pids[p]  do
				(
					pos = ms.position pids[p] 
				
					format "%,%,%\n" pos.x pos.y pos.z to:out_file
				)
			)
			
			close out_file
		)
		else
		(
	
		
		)
	)
)