Notifications
Clear all

[Closed] Reload RecentFiles.xml

So I have a script that runs through multiple .max-files, and I would like the files processed not to appear in the recent file list. My thought was that I could make a copy of the RecentDocuments.xml, then when the script is finished I would revert RecentDocuments.xml and reload it. The problem is that I can’t figure out how to reload the xml file. I thought maybe there was a function for this, does anyone know?

-- This doesn't work
xmlPath = getdir #maxData + "RecentDocuments.xml"
dotnet.loadAssembly "system.xml"
xmlDoc=dotNetObject "system.xml.xmlDocument"
xmlDoc.load xmlPath

The alternative would be to somehow prevent 3dsmax from updating recent files, I tried to use theHold to do this, but it didn’t seem to work with fileopen actions.

I would like to work with max files within the script without the files appearing in the recent files history. Does anyone have any ideas on how to do this?

8 Replies

what if you temporary set this file to read only ?

That was a very clever suggestion, sadly it didn’t seem to do anything

as i remember if you open files via MXS they don’t go to the Recent Files list until you save it. but you have an option of the saveMaxFile method (see the help and the flag useNewFile)

See, I wouldn’t have figured this out in a while I was way off track, I was sure that if there was a flag for this it would have to be on load, not sure if I ever would have checked for flags on save.

The RecentDocuments.xml does get updated immediately once you open a scene (with loadMaxFile), but if using merge instead (into an empty scene) combined with the flag useNewFile:false which you suggested, it works

I’m not sure if there is any drawbacks with merging in a scene instead of loading it? Anyway, this works great for me! Thank you professor, much appreciated!

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i might lose some scene data by merging instead of loading… global tracks, some persistent data
but performance has to be almost the same

maybe you can do a trick by making copy of every file from the list with the same name and load it. the same file path will not go multiple times in the recent files list

Hah, who say’s there isn’t creativity in programming, that actually works! Awesome suggestion, thanks again

 MZ1

Why you don’t use before-after open callback to revert back the file?

fn BeforeOpen =
(
	File = (getdir #maxdata)+"\\RecentDocuments.xml"
	TempFile = (getdir #maxdata)+"\\RecentDocuments.tmp"
	copy File TempFile 
)

fn AfterOpen =
(
	File = (getdir #maxdata)+"\\RecentDocuments.xml"
	TempFile = (getdir #maxdata)+"\\RecentDocuments.tmp"
	deletefile File
	copyfile TempFile File  
)
	
callbacks.removeScripts  id:#RecentDocuments
callbacks.addScript #filePreOpen "BeforeOpen()" id:#RecentDocuments
callbacks.addScript #filePostOpenProcess "AfterOpen()" id:#RecentDocuments

Sorry for the late response, the problem with this is that it doesn’t work. The xml file is indeed updated once you open a file, but it doesn’t look like it reads from it