Very strange bug - upper, lower case gets stuck on render output filenames!


#1

I can’t seem to change the render output filename casing via Maxscript.
e.g. “Myrender.jpg” to “myrender.jpg”

Using Max 2021.3 (also tested on 2019) I use Vray Next 3.2 and this issue affects all three render outputs:
Max output
Vray RAW
Vray separate

example:

vr = renderers.current
--first assignment, this all works fine
rendOutputFilename = @"\\NetworkDrive\Mypath\blabla\Max_.jpg"
vr.output_rawFileName = @"\\NetworkDrive\Mypath\blabla\Raw_.exr"
vr.output_splitfilename = @"\\NetworkDrive\Mypath\blabla\Sep_.exr"
Format "Max:	%\nRAW:	%\nSep:	%\n\n"rendOutputFilename vr.output_rawFileName vr.output_splitfilename

--second assignment, this does not work
rendOutputFilename = @"\\NetworkDrive\Mypath\blabla\max_.jpg"
vr.output_rawFileName = @"\\NetworkDrive\Mypath\blabla\raw_.exr"
vr.output_splitfilename = @"\\NetworkDrive\Mypath\blabla\sep_.exr"
Format "Max:	%\nRAW:	%\nSep:	%\n\n"rendOutputFilename vr.output_rawFileName vr.output_splitfilename

Try the above and you will see both format printouts are the same. First letters remain capitals after changing them to lower case.

If I change “Max_.jpg” to “maax_.jpg” then it works.
If I then change “maax_.jpg” to “max_.jpg” the result is “Max_.jpg”

It seems like 3dsMax keeps a cache of past file names and re-uses them whilst ignoring case changes.

In Max2021, If I change path manually via the UI, it works fine for the Max render output and Vray Separate channels output, but still fails to alter case on the Vray RAW output.
In Max 2019, I get the same issue via Maxscript, however when manually changing the outputs via UI, it fails on all three render outputs (not just RAW).

  • Is there a workaround for this?
  • Is there a deeper access into Max to assign these paths?
  • It certainly feels like 3dsMax is processing these paths with some flawed function under the hood. We need to be able to bypass it!

Any ideas / thoughts welcome!

Many thanks
Graham


#2

try to release assets before assigning a new path

asset = AssetManager.GetAsset filename #RenderOutput -- #RenderOutput for vray vfb paths & #Bitmap for rendOutputFilename
AssetManager.ReleaseReference (asset.GetAssetId())
gc()

#3

Thank you very much Serejah!

I got it working perfectly now, although, it needed two strange hacks !!

Here is my working test code with hack 1 - “sleep”:

rendOutputFilename = @"C:\Temp\MAX.jpg"
vr.output_rawFileName = @"C:\Temp\RAW.jpg"
vr.output_splitfilename = @"C:\Temp\SEP.jpg"

MaxAsset = AssetManager.GetAsset rendOutputFilename #Bitmap
RAWasset = AssetManager.GetAsset vr.output_rawFileName #RenderOutput
SEPasset = AssetManager.GetAsset vr.output_splitfilename #RenderOutput
AssetManager.ReleaseReference (MaxAsset.GetAssetId())
AssetManager.ReleaseReference (RAWasset.GetAssetId())
AssetManager.ReleaseReference (SEPasset.GetAssetId())
gc()
sleep 0.1 --without this sleep, the outputs stay stuck on upper case
rendOutputFilename = @"C:\Temp\max.jpg"
vr.output_rawFileName = @"C:\Temp\raw.jpg"
vr.output_splitfilename = @"C:\Temp\sep.jpg"

--check the resulting outputs
rendOutputFilename; vr.output_rawFileName; vr.output_splitfilename	

Even stranger, when I used the above in my main script I am creating it still did not work even with the sleep.
the only way I got it to work again was to remove the sleep and run the three ReleaseReference lines again:

rendOutputFilename = @"C:\Temp\MAX.jpg"
vr.output_rawFileName = @"C:\Temp\RAW.jpg"
vr.output_splitfilename = @"C:\Temp\SEP.jpg"

MaxAsset = AssetManager.GetAsset rendOutputFilename #Bitmap
RAWasset = AssetManager.GetAsset vr.output_rawFileName #RenderOutput
SEPasset = AssetManager.GetAsset vr.output_splitfilename #RenderOutput
AssetManager.ReleaseReference (MaxAsset.GetAssetId())
AssetManager.ReleaseReference (RAWasset.GetAssetId())
AssetManager.ReleaseReference (SEPasset.GetAssetId())
gc()
AssetManager.ReleaseReference (MaxAsset.GetAssetId())
AssetManager.ReleaseReference (RAWasset.GetAssetId())
AssetManager.ReleaseReference (SEPasset.GetAssetId())	
rendOutputFilename = @"C:\Temp\max.jpg"
vr.output_rawFileName = @"C:\Temp\raw.jpg"
vr.output_splitfilename = @"C:\Temp\sep.jpg"

--check the resulting outputs
rendOutputFilename; vr.output_rawFileName; vr.output_splitfilename	

It works, so I am not complaining, however I wonder if it is reliable??
All I can think is the AssetManager allows Maxscript to continue running beyond the ReleaseReference lines, before it finishes actually releasing!

Stumped! :face_with_raised_eyebrow: