PFlow Cache Manager (Beta): lo script permette di aggiungere e gestire il modificatore CacheDisk() legato ad un determinato pflow.

/*UPDATE 30/10/2014*/
/*Bug fix for cache update*/


(-- start srcipt

global ParticleCache_roll
try(destroyDialog ParticleCache_roll)catch()
rollout ParticleCache_roll "PFlow Cache Manager (beta)"
(
global spf = undefined
global 	PC_CPF = (pathConfig.getCurrentProjectFolder() )
global CfpS = (PC_CPF + "/Cache/")
global Cache_file_name

fn Cache_Name = 
(			
	particleFlow.BeginEdit()
	cont = 0
	for obj in ($* as array) do 
	(
		if classof obj == Cache_Disk do 
			(
				Cache_file_name = getSaveFileName()
				if Cache_file_name != undefined do
						(							
							Cache_file = Cache_file_name + "_" + spf.name + -- ".pfc" 	
							obj.Write_To_File = Cache_file
						)
				cont += 1
				)
	)
	if cont == 0 do	messagebox ("No Cache operators in current Pflow!") beep: false	
	particleFlow.EndEdit()
)				
fn Add_cache =	
(			
	particleFlow.BeginEdit()
	op1 = Cache_Disk()
	spf.insertAction op1 2
	op1.use_at = 2
	op1.Memory_Limit = 4194304
	makeDir CfpS all:true --try to make the directory
	if doesFileExist CfpS then --if it does exist,
	op1.Write_To_File = (CfpS + "_" + spf.name + ".pfc" 	)
	else print ("Error make dir " + CfpS)
	particleFlow.EndEdit()
			 
) --end fn Add_cache
fn Update_cache = 
(
	cont = 0
	for obj in ($* as array) do 
	(
		if classof obj == Cache_Disk do
			(
					particleFlow.EndEdit()
					spf.enable_particles = true
					obj.update()
					cont += 1
			)
	)
	if cont == 0 do	messagebox ("No Cache operators in current Pflow!") beep: false	
--)
) --end fn Update_cache
	
fn Clear_cache = 
(
	particleFlow.BeginEdit()
	cont = 0
	for obj in ($* as array) do 
	(
		if classof obj == Cache_Disk do 
			(
				obj.clearAll()
				cont += 1
			)
	)
	if cont == 0 do	messagebox ("No Cache operators in current Pflow!") beep: false

) --end fn Clear_cache	
					
fn Del_cache = 
(		
	particleFlow.BeginEdit()
	cont = 0
	for obj in ($* as array) do 
	(
		if classof obj == Cache_Disk do 
			(
				delete obj
				cont += 1
			)
	)
	if cont == 0 do	messagebox ("No Cache operators in current Pflow!") beep: false
	particleFlow.EndEdit()
) --end fn Del_cache				
					--== MAIN INTERFACE ==--			
				
pickbutton Select_PFlow "Select Pflow " width: 120 pos:[15,5]
button Cache_Name_buttom "Cache file:" width: 120 pos:[150,5]
group "Cache Option" 
(
	button Add_cache_button "Add Cache_Disk" width: 120 pos:[15,60]
	button Update_cache_button "Update all Cache_Disk " width: 120 pos:[150,60]
	button Clear_cache_button "Clear all Cache_Disk " width: 120 pos:[150,90]
	button Del_cache_button "Delete all Cache_Disk " width: 120 pos:[15,90]	
	Button open_pflow "Open/Close Pflow" height: 30 pos:[15,120]	
	Button Open_eve_ren "Open Event renamer" height: 30 pos:[150,120]	
	Button Help "Help" pos:[125,160]
	label Copyright "--== Silver3d.it ==--" pos:[95,190]		
)
					--== Button Actions ==--	
on Select_PFlow picked PF do
(
	if ((PF.classid)[1]) != 1345457306 
		then (
				messagebox "Select a Pflow elements!"
				clearSelection()
			)
		else ( 
				Select_PFlow.text = PF.name
				spf = PF
			 )
)				
on Cache_Name_buttom pressed do
(
	(
		If spf != undefined then Cache_Name() else messagebox "Select a Pflow first!" beep: false	
	)
)
on Add_cache_button pressed do
(	
	(
		If spf != undefined then Add_cache() else messagebox "Select a Pflow first!" beep: false	
	)
)				
on Update_cache_button pressed do
(
	(
		If spf != undefined then Update_cache() else messagebox "Select a Pflow first!" beep: false	
	)
)		
on Clear_cache_button pressed do
(
	(
		If spf != undefined then Clear_cache() else messagebox "Select a Pflow first!" beep: false	
	)
)		
on Del_cache_button pressed do
(
	(
		If spf != undefined then Del_cache() else messagebox "Select a Pflow first!" beep: false	
	)
)	
on Open_eve_ren pressed do
(
	filein "G:/MyScript/Event_rename.ms"
)
on open_pflow pressed do (actionMan.executeAction 135018554 "32771")
on Help pressed do messageBox "PFlow Cache Manager (beta) - 2014 \n Select a Pflow and control the CacheDisk() function!" beep: false
)	--end rollout

createDialog ParticleCache_roll width: 280

)--end script