[Closed] Delete MR Photon Map with script
Hello i’m looking for a way to delete the Global Illumination / Caustic file (Photon Map file) in Mental Ray.
To delete the FinalGather file it’s just to execute this line
renderers.current.DeleteFinalGatherFile
But i find nothing in the MAXScript Reference about how to delete the Photon Map…
Should be easy once you know.
Thanks
well you can get the Photon Map filename from the properties so just use the deleteFile function on it:
deleteFile renderers.current.PhotonMapFilename
Works well for deleting the resulting file, and i can easely fake an itendical query window by using queryBox.
Only problem i discovered is that the PhotonMapFilename from the real query ends with the filename[xxxx].extension while my query express it simply like filename.extension.
If the cache is split up into one file per frame that makes a sequence deleteFile renderers.current.PhotonMapFilename will not work. It will only remove a single file.
But, i worked out some code that can deal with this using wildcards.
photonFolder = pathConfig.removePathLeaf renderers.current.PhotonMapFilename
photonFile = pathConfig.stripPathToLeaf renderers.current.PhotonMapFilename
photonFullPath = pathConfig.appendPath photonFolder photonFile
photonFileSplit = (filterString (photonFile as string) ".")
newPhotonFileName = ((photonFileSplit[1] + "[xxxx]" + "." + photonFileSplit[2]) as string)
newPhotonFullPath = ((photonFolder + "\\" + newPhotonFileName) as string)
if queryBox ("The following files will be deleted. Confirm?"+"
"+((newPhotonFullPath) as string)) title:"Delete File(s)" then
(
loopDel = getFiles (photonFolder + "\\" + photonFileSplit[1] + "*" + "." + photonFileSplit[2])
for i in 1 to loopDel.count do deleteFile loopDel[i]
)
It behaves just like the original.
Thanks alot for the help!