PDA

View Full Version : Delete MR Photon Map with script


Swahn
09-30-2009, 09:22 AM
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

Gravey
09-30-2009, 10:03 AM
well you can get the Photon Map filename from the properties so just use the deleteFile function on it:deleteFile renderers.current.PhotonMapFilename

Swahn
09-30-2009, 10:13 AM
well you can get the Photon Map filename from the properties so just use the deleteFile function on it:deleteFile renderers.current.PhotonMapFilename

I'll try it.
Thanks

Swahn
09-30-2009, 02:50 PM
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?"+"\n\n"+((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!

CGTalk Moderation
09-30-2009, 02:50 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.