Enabling and disabling options

Moderator: GiD Team

Post Reply
barnacle
Posts: 12
Joined: Sat Feb 28, 2015 1:51 pm

Enabling and disabling options

Post by barnacle »

Dear GiD-Team,

I have introduced two options to my problem type called "Generate" and "Simulate". The "Generate" option calls a Tcl-script that prepares my simulation (it does some rotations, creates several meshes and exports them). The Tcl-script then realoads the GiD-project in the state before execution of the script and enables the "Simulate" option (changes its color from grey to black). The "Simulate" option is coupled to "GiD_Process Mescape Utilities Calculate".

There are threething it would like to be able to do now:

1. First I would like to check the color of the "Simulate" option. If it is grey (not enabled after "Generate") I would like it to produce an error message. That means I need to get the options current color. How to do that?
2. If the "Simulate" option is enabled (it is black), I would like it to start the calculation (via "GiD_Process Mescape Utilities Calculate") from the current state where no mesh has been generated inside the project window. So I need to circumvent the "Don't forget to generate the mesh" function.
3. After anything changes (like "Changes to save(0/1): 1" in "GiD_Info list_entities PreStatus") I would like to automatically disable the "Simulate" option again. Is there a function like "AfterAnythingChange" combining function like AfterAssignMaterial?

Thanks for your help,

barnacle
User avatar
escolano
Posts: 1922
Joined: Sun Sep 05, 1982 10:51 pm

Re: Enabling and disabling options

Post by escolano »

The normal workflow of GiD is that pressing calculate, automatically evaluate the .bas templates to export the current information (mesh, conditions,...) and starts the calculation.
To olny exports the calculation file/s is possible to use Files->Export->Calculation file.
Maybe you can adapt your current workflow, e.g. an special 'Prepare' option or wizard could do the geometrical operations, rotations, etc, and mesh generation
and then our standard 'Calculate' button could write the calculation files and run the simulation, without need to do special things.

In any case, about your specific questions
1- You can study a little the 'proc SetCalculateMenuState' of the file tclfileP.tcl, but maybe is not a good idea to be so interleaved with the GiD behaviour, any future change of our Tcl code will break your problemtype.
Instead of ask the curret menu color of your 'Simulate' menu, you can store this state in a variable just when you set this color.
e.g. to get the menu color of Calculate->Calculate (unrecommended)

Code: Select all

set menu_name "Calculate#C#menu"
set i [ GiDMenu::_FindIndex $menu_name PRE]
set option_name [list "Calculate#C#menu"]
set position [lindex [split [GiDMenu::_FindOptionIndex $i $option_name PRE] ,] end]
set color [$menuname entrycget $position -foreground]
2- If your calculation don't require any mesh then is possible to overcome the "Don't forget to generate the mesh" validation setting the GiD variable 'CalcWithoutMesh' to 1
e.g. from Tcl

Code: Select all

GiD_Set CalcWithoutMesh 1
3- a GiD-Tcl event like AfterAnythingChange doesn't exists.
You can know the list of current events reading the manual, and also with this Tcl command:

Code: Select all

-np- WarnWinText [GiD_Info events]
About the value of the flag "Changes to save(0/1)" of [GiD_Info list_entities PreStatus], it could be obtained directly with [GiD_Info project AreChanges]

We can study to add some new events in future GiD versions (e.g. raised when the value of the flag "Changes to save(0/1)" is modified and the model has to be saved)
barnacle
Posts: 12
Joined: Sat Feb 28, 2015 1:51 pm

Re: Enabling and disabling options

Post by barnacle »

Thanks!

Helped a lot!

Greetings
Post Reply