Notifications
Clear all

[Closed] Using Callbacks to stop a save or load

Ok, so this is driving me CRAZY.

I have created a callback to check the path of the file the user has specified. What I am trying to do is stop the load when the path is not valid (IOW. the user is opening a file that he/she is not supposed).

For the life of me I can not find a way to do that in the help file.

I can let the load happen then do the check in a postopenprocess and force a reset, that can work no problem.

But how can I stop a save from happening (if that same user is trying to save to the wrong location).

Any ideas out there?

-Paul

8 Replies

hi paul,

Im sure you’ve seen doesfileexist(), that would probably help with the load callback. as for the save, Im not sure if you can stop a save. Although there is a pre-save callback I cant work out how you actually stop it from saving at this point. The only thing i can think of is physically moving the file to the correct location if it was ‘illegally’ saved. There is a filesystemwatcher class in dotnet that Martijn van Herk (MagicM) posted an example of that would monitor a folder in the background and provide a method to do this. I suppose you could also have you own save/load function, that replaces the standard max ones, bound to the same hotkey that only saves/loads after your conditions are met.

In times like these I would shout help very loudly to Richard A (zeboxx2) !

 PEN

Hey Paul, I don’t think that you can stop the process from happening, not sure what you are doing but if you wrote your own save/load dialog you could filter out the files you don’t want them seeing.

the last time I poked at something like this, I couldn’t prevent the save*… the best I could do was rename the original, let it save, delete the new file and restore the old.

  • setting the original file’s #readOnly or #system file attributes gets ignored
  • opening a file handle lock (openFile <file> mode:“a”) gets ignored

Maybe setting the file handle lock from .NET does get respected, or .NET allows you to protect a file from overwriting more efficiently. I know that at least API/SDK-wise it’s possible to prevent a file save, so might just be a matter of getting an extension to expose that (and then, of course, distributing that extension with the script, etc. etc.)

I have thought of creating a save and load dialog and that would do the trick but that would not prevent someone from just using the save and open command.

Even if we remove the menu item they could still add it as a hotkey.

For the load I think I am covered. Once the load process is complete I am forcing a max reset.

As for the save, renaming the original file letting the save happen, then deleting the new file and renaming the original file back is the work around.

Basically, If a user “checks out” a file, only that user should be able to “check in” that file.

That is what I am going for. I guess making save and load dialogs are the best way to go.

-Paul

Have you thought of using a program like Alienbrain or CVS?

 PEN

I wrote a system for this Paul using lots of dot net and XML as the data base. Worked very well for a TV series that was done. The save load was replaced with a tool that showed a directory structure of the project and allowed for just double clicking on the file that was needed.

Here it is:

1 Reply
 JHN
(@jhn)
Joined: 11 months ago

Posts: 0

Paul, could you give an estimate on how much time it took you to write such a tool? We’re trying to get an animated series of the ground and I would like to have something like that too, for in and out checking of files, I think it would at least take some days too develop. Does only work with xml files? Don’t you have problems with “same time” accessing of files?

Maybe it would be great if you made a DVD about managing production pipelines with custom tools, going throughout the pipeline from a TD/TA and artist perspective. I’d definitely be interested!

Thanks for showing all this stuff!
-Johan

My question is, what did you do with the built in Save and Load commands?

Did you find a way to lock them down or did you just threaten to chain the artists to their desks if they saved or loaded without using the correct tool?

(I’m in a funny mood – lots of 12 hour days not including the 2 to 3 hours a day of LA driving).

God I HATE Sepulveda Pass. Any other SP haters out there?