How to force the user to salve a model before running it

Hi.

I would like to know how to force the user to salve a model before one calculates it. I want to do this because i want to get the path of this file. Once salved, how do i get the path of the file?

Also, how do i show a message in a small window while the model is running?

Thanks in advance.

In place of ‘salve’, reads ‘save’.

My current recommendation is not force to save (it is easier for the user to do a fast test), is the model is not saved it has name “UNNAMED” and the its files are saved in a temporary location.

Your calculation files can be also written to this temporary folder, and if the user save it with a name all temporary files are written in the selected user location.

You can get this path to save your files with
GidUtils::GetDirectoryModel
(if saved return the name, otherwise the temporary name)

and can know if was saved with a named with
GidUtils::ModelHasName

If do you want in any case to force be saved before calculate can implement for example the event
proc GiD_Event_BeforeWriteCalculationFile { file } {
}
https://gidsimulation.atlassian.net/wiki/spaces/GCM/pages/2379943778/Calculation+file
here can check if was saved, and otherwise call our Tcl procedure
DoProjectSaveAs
to open a file dialog to ask the user.

And about calculation, you can implement the event to detect when the calculation start or finish
proc GiD_Event_BeforeRunCalculation { batfilename basename dir problemtypedir gidexe args } {
}
proc GiD_Event_AfterRunCalculation { basename dir problemtypedir where error errorfilename } {
}
but I think that this is not necessary. GiD will show it own messages, and can show the console (or log file) output of the calculation program, if any in Calculate->View process info… (you must declare this log file in the .bat file, with a special OutPutFile comment, and/or ErrorFile in case of print error messages in other file)