So while doing updates to a tool that’s made for batching commands through a big list of files, I was trying to think of a way to not have popups for missing references (some of our artists tend to have some scale models they use that aren’t on source control that they tend forget to unload) and I found this little flag buried in the file command called prompt. What it does if set to false is skips some other prompts on file open including missing reference prompts. That’s totally what I was looking for, but the problem is, it saves that setting so the next time you run any file operation and don’t set it back to true, it’ll just automatically unload any missing references.
I usually use pyMEL, so just tried it with openFile, turns out that works for it, that it’s just an undocumented flag. The issue is, I don’t want it to affect the default open behavior after the batch has run, but I can’t find a way to just set or whatever variable it seems to be saving to in the Maya Session (doesn’t save to option variables) without running another file command. Ideally, the script would open the file, then just immediately set prompts back to true right away so if anything goes wrong, it’s not stuck with the non-default settings we just went with.
I kinda found a little workaround where I open with prompt set to false, then put the batch command in a try statement, then in the except block, I just run newScene setting it back to true, then at the end, if the command runs correctly all the way through, it does newScene. But I’m not a fan and would like to try and find a way to just have it set without the necessity of a file operation.
Here’s kinda of what I’m talking about
# What I have
for path in someFiles:
pm.openFile(path, f=True, prompt=False)
try:
someFunction()
except:
pm.newFile(f=True, prompt=True)
# Handle errors
pm.newFile(f=True, prompt=True)
# What I'd like
for path in someFiles:
pm.openFile(path, f=True, prompt=False)
pm.changeSomeFileSetting(prompt=True)
try:
someFunction()
except:
# Handle Errors
Kinda nitpicky, big reason I want to avoid having to do a new file thing is so people can see the state of the file when it errors rather than just trashing the scene. Has anyone ever dealt with going around the file command to change that setting? Or have some other way to bypass those dialogs?