PRT generation with maxscript

Hello !

I’m trying to script a production tool that would allow me to automate the PRT generation. In my scenes, I have many particle systems that I want to bake separately. After some research, I only found the “ParticleOStream” function, but it only seems to fill a PRT from given datas… Which is not what i’m looking for.
So, is there a way to specify a export path, to specify to look for Thinking Particles systems, and to hit the “Save Particle” button ?
Are some Krakatoa functions directly reachable via maxscript ?

I’m not sure if it’s clear, so feel free to ask me for details, and pardon my english, I’m french, and voila :wink:

Thank you in advance !

Totally clear.

The complete Krakatoa UI is a (very large) MAXScript. So anything you see in the UI can be done via scripting, and you can dissect the KrakatoaGUI.ms file to see how we do it.

That being said, you will have to do some work to get exactly what you need as we don’t expose a clean API for people to do this with a single function.
Here are the basics:

--First, hide all objects except for the one you want to save
--Write your own code here - Krakatoa will save those that are visible and are enabled for saving via the source options

--Set the renderer to Save Particles mode and enable the source type, e.g. Thinking Particles.
FranticParticles.SetProperty "ParticleMode" "Save Particles To File Sequence"
FranticParticles.SetProperty "RenderThinkingParticles" True
--To see a list of all possible Krakatoa properties accessible via GetProperty/SetProperty, call
--print (FranticParticleRenderMXS.getPropNames())
--The 16 source switches are as follows - you can enable them all if you want:
/*
FranticParticles.SetProperty "RenderParticleFlowGeometry" True
FranticParticles.SetProperty "RenderParticleFlowBBox" True
FranticParticles.SetProperty "RenderParticleFlowPhantom" True
FranticParticles.SetProperty "RenderFumeFX" True
FranticParticles.SetProperty "RenderPRTHair" True
FranticParticles.SetProperty "RenderPRTCreator" True
FranticParticles.SetProperty "RenderPRTSource" True
FranticParticles.SetProperty "RenderMaxParticles" True
FranticParticles.SetProperty "RenderThinkingParticles" True
FranticParticles.SetProperty "RenderGeometryVertices" True
FranticParticles.SetProperty "RenderKrakatoaLoaders" True
FranticParticles.SetProperty "RenderGeometryVolumes" True
FranticParticles.SetProperty "RenderPRTSurface" True
FranticParticles.SetProperty "RenderPhoenixFD" True
FranticParticles.SetProperty "RenderPRTField" True
FranticParticles.SetProperty "RenderStoke" True
*/

--Then set the save output path:
FranticParticles.SetProperty "ParticleFiles" "C:\\temp\\testPRTSaving_.prt"

--Set the channels you want included. Extend the string with channel, type, arity as needed.
FranticParticles.setProperty "ActiveParticleChannels" "Position,float32,3,Velocity,float16,3,Color,float16,3,ID,int32,1"

--The following are not mandatory, but are a good way to verify your changes succeeded:
try(Krakatoa_GUI_Main.Refresh_GUI())catch() --update the Main Rollout if open
try(Krakatoa_GUI_SaveParticles.Refresh_GUI())catch() --update the Save Rollout if open
	
--Now let's set up the render time and save to disk...
renderSceneDialog.close() --close the render dialog
rendTimeType =3 --set the time to custom range
rendStart = 1 --set the first frame to save
rendEnd = 30 --set the last frame to save
max quick render --launch the renderer
	
--then repeat by hiding the particle object and unhide the next one. Use a loop, obviously... ;)

Wow !
Thank you VERY MUCH ! This is more than I expected.
I’m going to try all this stuff, but it seems to be exactly what I was looking for.

Thanks again :wink: