Page 1 of 1

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

Posted: Wed Aug 09, 2023 4:09 pm
by Daniel
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.

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

Posted: Wed Aug 09, 2023 6:49 pm
by Daniel
In place of 'salve', reads 'save'.

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

Posted: Tue Sep 12, 2023 5:51 pm
by escolano
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/wik ... ation+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)