Is your question about modifying a script? If so, you should change the topic to Scripting so more scripters and developers see it. Also post any relevant portions of your script.
step1: start edit command
step2: edit model
step3: save -> this needs to be checked because it is invalid to save with the modified model as the stop edit command has not been clicked. so a warning needs to be given and the save cancelled.
the question is how do i interfere with the save to cancel it. Hope i am clear.
Valid steps=>
step1: start edit
step2: edit model
step3: stop edit
step4: save
@HepChan – I had a similar issue that I had to solve to avoid corrupted data that is being serialized during save. The way I have solved it is by creating static variable flags that I can check to determine the state of my application, and then using those flags to hinder the save process using message boxes and while loops with Thread.sleep to prevent the saving from occuring until after the critical process is finished. So, for your case, I would recommend:
On StartEdit, set a bool flag “EditingInProcess” to true
On BeforeSave, check the EditingInProcess flag. There are a couple ways to handle this, but the simplest is this: While true, use MassageBox.Show(“Editing is in process, please complete and Retry.”). When the user hits the “Retry” or “OK” button, the EditingInProcess flag gets checked again, and if the user has not finished editing, the messagebox shows again
On StopEdit, set EditingInProgress to false
User hits OK and saving thread is allowed to continue
You can do some advanced stuff like just showing a messagebox with “File will be saved when editing is complete” and just do a System.Threading.Thread.Sleep inside the while loop, but your setup may vary so use with caution. I use thread sleep but with a limit that transitions to a manual retry model after a certain amount of time to prevent long, locked up states with no feedback.
Hope this helps someone in the future, even if this is no longer an issue for the OP.