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

Moderator: GiD Team

Post Reply
Daniel
Posts: 20
Joined: Fri Feb 03, 2023 4:08 pm

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

Post 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.
Daniel
Posts: 20
Joined: Fri Feb 03, 2023 4:08 pm

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

Post by Daniel »

In place of 'salve', reads 'save'.
User avatar
escolano
Posts: 1922
Joined: Sun Sep 05, 1982 10:51 pm

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

Post 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)
Post Reply