Render to Texture Issue - Renaming Existing Elements

Hello everyone, thanks for taking the time to read.

I’m trying to make a script that will alter some scene/material/uv parameters and rename all the existing render to texture elements of a given object into a specific path. The first part of the script works great but I have really hit a brick wall with something so simple as changing a path and filename…

I’m having really weird issues, the code below only works occasionally. Sometimes it works 5 times in a row and sometimes not even once.

Should this code work, even on its own in a separate script?

sMapFolder= "C:\\1\\BakeOutput"
 

The actual bake preparation function:
 
		np = $.INodeBakeProperties
		myElement = np.GetBakeElement 1
 
		fType = getFilenameType myElement.fileName
 
		myElement.fileName = sMapFolder+"\\"+("some string")+(ftype)

I have tried all I could think off but I’m unable to debug the issue, it’s really inconsistent. Funny thing, the RTT_Data array actually shows the correct path and the Listener shows the path and filename that was supposed to be applied.

Btw, the render elements are manually inserted, they vary from object to object, that is why they are not being added via maxscript.

I’m a bit lost regarding the Max Render to Texture script, and I might have missed something simple, any tips would be great.

Thanks!

Oh… Just make myElement.filenameUnique = true.
Wish I knew that before spending so much time digging around the RTT scripts :x: