TCL/TK EXTENSION |
In this chapter, there are exposed the advanced features of GiD in terms of expandability and total control. The Tcl/Tk extension is the way to create script files to automatize any process created with GiD. With this language it is possible to add new windows or new functionalities to the program.
For more information about the Tcl/Tk programming language look at www.scriptics.com.
If such Tcl file exists, it must be in the problem type directory; the
name of the file has to be the problem type name with the .tcl
extension.
Event procedures |
The structure of problem_type_name.tcl
can optionally implements some of these Tcl
prototype procedures (and other user defined procedures).
The procedures listed below are automatically called by GiD. Their syntax correspond
to standard Tcl/Tk language:
proc InitGIDProject { dir } { ...body... } proc InitGIDPostProcess {} { ...body... } proc EndGIDProject {} { ...body... } proc EndGiDPostprocess {} { ...body... } proc AfterOpenFile { filename format error } { ...body... } proc LoadGIDProject { filespd } { ...body... } proc SaveGIDProject { filespd } { ...body... } proc LoadResultsGIDPostProcess { file } { ...body... } proc BeforeMeshGeneration { elementsize } { ...body... } proc AfterMeshGeneration { fail } { ...body... } proc SelectGIDBatFile { dir basename } { ...body... set value ... return $value } proc BeforeRunCalculation { batfilename basename dir problemtypedir gidexe args } { ...body... } proc AfterRunCalculation { basename dir problemtypedir where error errorfilename } { ...body... } proc ChangedLanguage { language } { ...body... } proc BeforeWriteCalcFileGIDProject { file } { ...body... set value ... return $value } proc AfterWriteCalcFileGIDProject { file error } { ...body... set value ... return $value } proc AfterTransformProblemType { file oldproblemtype newproblemtype } { ...body... } proc LoadFileInGidUnknowExtension { filename } { ...body... }
dir
argument, which is the absolute path to the problem_type_name.gid
directory, which can be useful inside the routine to locate some alternative files.
filename
: the full name of the readed file.
format
: ACIS_FORMAT, DXF_FORMAT, GID_BATCH_FORMAT, GID_GEOMETRY_FORMAT, GID_MESH_FORMAT
, IGES_FORMAT, NASTRAN_FORMAT,PARASOLID_FORMAT,SHAPEFILE_FORMAT,STL_FORMAT or VDA_FORMAT
error
: boolean 0 or 1 to indicate an error when reading.
filespd
argument, which is the path of the file which is being opened, but with a .spd
extension (specific problemtype data). This path can be useful if you want to write specific information of the problem type in a new file.
filespd
argument, which is the path of the file which is being saved, but with a .spd
extension (specific problemtype data). This path can be useful if you want to write specific information of the problem type in a new file.
elementsize
argument the user desired mesh size. This event can be used typically to automatically assign some condition.
fail
argument a true value if the mesh is not created.
value
the alternative pathname of the bat file.
For example must be used as a trick to select a different analysis between a list of bat
calculation files.
batfilename
: the name of the bat file to be run. see section Executing an external program.
basename
: the short name model
dir
: the full path to the model directory
problemtypedir
: the full path to the problemtype directory
gidexe
: the full path to gid
args
: an optional list with other arguments
basename
: the short name model
dir
: the full path to the model directory
problemtypedir
: the full path to the problemtype directory
where
: must be local
or remote
. (remote if it was run in a server machine, using ProcServer)
error
: return 1 if an calculation error wal detected.
errorfilename
: an error filename with some error explanation, or none if everything was ok.
-cancel-
as value
then nothing will be written.
file
: the name of the output calculation file
-cancel-
as value
then the calculation is not invoked.
file
: the name of the output calculation file
error
: an error code if exists some problem writting the output calculation file
file
: the name of the model to transform
oldproblemtype
: the name of the previous problemtype
newproblemtype
: the name of the problemtype to be transformed
filename
: the name of dropped file
Note: To use Tcl to improve the capabilities of writing the
calculations file, it is possible to use the command *tcl
in the
template file (.bas file); see section Specific commands for details.
Control functions |
GiD offers the following Tcl functions:
Process function |
GiD_Process command_1 command_2 ...
This is a simple function but really powerful. It is used to enter commands directly inside the central event manager. The format of the command has to be a string with the same style as if they were entered by typing on the command line interface.
You have to enter exactly the same sequence as you would do interactively,
including the escape sequences, using the word escape
, and
selecting the menus and operations used.
It is possible to obtain the exact commands that GiD needs, by checking the right buttons toolbar (Utilities > Graphical > Toolbars). It's also possible to save a batch file (Utilities > Preferences > Batch file) and check there the commands used during the GiD session.
One simple example to create one line:
GiD_Process escape escape escape escape \ geometry create line 0,0,0 10,0,0 escape
Info function |
GiD_Info option
This function provides any information about GiD, the current data or
the state of any task inside the application. Depending on the arguments introduced after the GiD_Info
sentence, GiD will output different information:
GiD_Info materials
"Air Steel Aluminium Concrete Water Sand"
GiD_Info materials Steel
"1 Density 7850"
GiD_Info conditions ovpnt
"Point-Weight Point-Load"
GiD_Info conditions Point-Weight
"ovpnt 1 Weight 0"
GiD_Info conditions Point-Weight geometry
"E 1 - 2334 , E 2 - 2334 , E 3 - 343"
GiD_Info Conditions -localaxes Concrete_rec_section mesh 2
{E 2 - {4.7123889803846897 1.5707963267948966 0.0} N-m 0.3 0.3 HA-25}
GiD_Info back_layers
Layer2_*back*
GiD_Info layers
"layer1 layer2 layer_aux"
GiD_Info layers -on
"layer1 layer2"
GiD_Info layers -entities lines layer2
"6 7 8 9"
GiD_Info gendata
"2 Unit_System#CB#(SI,CGS,User) SI Title M_title"
NONE
if there's no mesh).
GiD_Info Project
"cmas2d e:\models\car_model 1 layer3 MESHUSE 0 normal YESPOST nodebug C:\TEMP\gid2 0 1.4"
GiD_Info Project ModelName
"e:\models\car_model"
NumPoints
).
1
followed by a list with all types of element used in the mesh. GiD_Info Mesh
"1 Tetrahedra Triangle"
GiD_Info Mesh MaxNumNodes
"1623"
GiD_Info MeshQuality MinAngle Triangle 20 60 4
"13 34 23 0"
YES
if the user is in the GiD postprocess, and NO
, if the user is not.
#000000
would be black, and #FFFFFF
would be white.
#000000
would be black, and #FFFFFF
would be white.
#000000
would be black, and #FFFFFF
would be white.
Opaque
or Transparent
depending on the current transparency. Transparency is chosen by the user in the Select & Display Style window.
Massive
if the option Massive of the window Select & Display Style is selected. It returns Hollow
if that option is not activated.
Deformed
or Original
Deformed
or Original
.
STD
appears if the contour limit value is the default value, and USER
, if it's defined by the user.
Geometry Mesh None
)
Geometry Mesh None
)
#000000
would be black, and #FFFFFF
would be white.
255#255#255
would be white.
GiD_Info list_entities status
Project name: UNNAMED
Problem type: UNKNOWN
Changes to save(0/1): 1
Necessary to mesh again (0/1): 1
Using LAYER: NONE
Interval 1 of 1 intervals
Degree of elements is: Normal
Using now mode(geometry/mesh): geometry
number of points: 6
number of points with 2 higher entities: 6
number of points with 0 conditions: 6
number of lines: 6
number of lines with 1 higher entities: 6
number of lines with 0 conditions: 6
number of surfaces: 1
number of surfaces with 0 higher entities: 1
number of surfaces with 0 conditions: 1
number of volumes: 0
number of nodes: 8
number of nodes with 0 conditions: 8
number of Triangle elements: 6
number of elements with 0 conditions: 6
Total number of elements: 6
Last size used for meshing: 10
Internal information:
Total MeshingData:0 Active: 0 0%
2 3 6 45
) a range of entities (example: entities from 3 to 45, would be 3:45
) or a layer (example: layer:layer_name
).
GiD_Info list_entities Points 2 1
POINT
Num: 2 HigherEntity: 1 conditions: 0 material: 0
LAYER: car_lines
Coord: -11.767595 -2.403779 0.000000
END POINT
POINT
Num: 1 HigherEntity: 1 conditions: 0 material: 0
LAYER: car_lines
Coord: -13.514935 2.563781 0.000000
END POINT
GiD_Info list_entities lines layer:car_lines
STLINE
Num: 1 HigherEntity: 0 conditions: 0 material: 0
LAYER: car_lines
Points: 1 2
END STLINE
STLINE
Num: 13 HigherEntity: 0 conditions: 0 material: 0
LAYER: car_lines
Points: 13 14
END STLINE
GiD_Info list_entities -more Lines 2
STLINE
Num: 2 HigherEntity: 2 conditions: 0 material: 0
LAYER: Layer0
Points: 2 3
END STLINE
LINE (more)
Length=3.1848 Radius=100000
Higher entities surfaces: 1 3
END LINE
GiD_Info parametric line 26 deriv_t 0.25
8.060864 -1.463980 0.000000
GiD_Info check volume 5 orientation
2 {4 38}
2 3 6 45
) a range of entities (example: entities from 3 to 45, would be 3:45
).
Example: GiD_Info ListMassProperties Lines 13 15
LINES
n. Length
13 9.876855
15 9.913899
Selected 2 figures
________________________
Total Length=19.790754
Special functions |
It exists some special commands to control the redraw and wait state of GiD:
.central.s disable graphics 'value'
The value 0/1 Enable/Disable Graphics (GiD doesn't redraw)
EXAMPLE to disable the redraw:
.central.s disable graphics 1
.central.s disable graphinput 'value'
The value 0/1 Enable/Disable GraphInput (enable or disable peripherals: mouse, keyboard, ...)
EXAMPLE to disable the peripherals input:
.central.s disable graphinput 1
.central.s disable windows 'value'
The value 0/1 Enable/Disable Windows (GiD displays, or not, windows which require interaction with the user)
EXAMPLE to disable the interaction windows:
.central.s disable windows 1
.central.s waitstate 'value'
The value 0/1 Enable/Disable the Wait state (GiD displays a hourglass cursor in wait state)
EXAMPLE to set the state to wait:
.central.s waitstate 1
Usually these command are used jointly:
EXAMPLE
#deactivate redraws, etc wit a widget named $w $w conf -cursor watch .central.s waitstate 1 update .central.s disable graphics 1 .central.s disable windows 1 .central.s disable graphinput 1 ... #reactivate all and redraw .central.s disable graphics 0 .central.s disable windows 0 .central.s disable graphinput 0 GiD_Process "redraw" $w conf -cursor "" .central.s waitstate 0
Note: It's more recommended for a tcl developer, to use the more 'user-friendly' procedures defined
inside the file 'dev_kit.tcl' (located in the directory \scripts).
For example, to disable and enable redraws, you can use:
::GidUtils::DisableGraphics ::GidUtils::EnableGraphics
It exists other GiD-tcl special commands to directly manage materials, conditions, intervals or create nodes and elements, as follows:
GiD_CreateData create|delete material ?<basename>? <name> ?<values>?
To create or delete materials
Example:
GiD_CreateData create material Steel Aluminium {3.5 4 0.2} GiD_CreateData delete material Aluminium
GiD_AssignData material|condition <name> <over> ?<values>? <entities>
To assign materials or conditions over entities
Example:
GiD_AssignData materials Steel Surface {1 5} GiD_AssignData condition Point-Load Nodes {3.5 2.1 8.0} {4 8} GiD_AssignData condition Face-Load face_elements {3.5 2.1 8.0} {15 1 18 1 20 2}
GiD_ModifyData materials|intvdata|gendata ?<name>? <values>
To change all field values of materials, interval data or general data
Example:
GiD_ModifyData materials Steel {2.1e6 0.3 7800} GiD_ModifyData intvdata 1 ... GiD_ModifyData gendata ...
GiD_AccessValue set|get materials|conditions|intvdata|gendata ?<name>? <question> ?<attribute>? <value>
To change only some field value of materials, interval data or general data
Example:
GiD_AccessValue set gendat Solver Direct
GiD_IntervalData <mode> <number>|?copyconditions?
To create, delete or set a interval data
Example:
set current [GiD_IntervalData set] GiD_IntervalData set 2 set newnum [GiD_IntervalData create] set newnum [GiD_IntervalData create copyconditions]
GiD_LocalAxes <mode> <name> ?<type>? <Cx Cy Cz> <PAxex PAxey PAxez> <PPlanex PPlaney PPlanez>?
To create delete or modify local axes.
For the 'exists' operation, if only it's specified the <name> field, then it's returned 1 when this name exists, and 0 if not.
If also is specified the other values, then <name> is ignored.
The returned value is:
-1 if match the global axes.
-2 if match the automatic local axes.
-3 if match the automatic alternative local axes.
0 if it does not match with any axes.
<n> if match the user defined number <n> (n>0) local axes.
Example:
GiD_LocalAxes create "axes_1" rectangular C_XY_X {0 0 0} {0 1 0} {1 0 0} GiD_LocalAxes delete axes_1 GiD_LocalAxes exists axes_1 GiD_LocalAxes exists "" rectangular C_XY_X {0 0 0} {0 1 0} {1 0 0} this last sample returns -1 (equivalent to global axis)
GiD_Geometry create|delete|get|list point|line|surface|volume <num>|append <data>
To create, delete, get data or list the identifiers of geometric entities
Examples:
GiD_Geometry create surface 1 nurbssurface Layer0 4 1 1 2 2 0 0 {1 1} {4 1} {3 1} {2 1} \ {0.17799 6.860841 0.0} {-8.43042200 6.86084199 0.0} {0.17799400 0.938510 0.0} \ {-8.43042 0.938510 0.0} 0.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 GiD_Geometry list points 1: layer:layer_name
GiD_Mesh create|delete|edit node|element <num>|append <elemtype> <nnode> <N1 ... Nnnode> ?<matname>? | <x y z>
To create or delete mesh nodes or elements.
Examples:
GiD_Mesh create node append {1.5 3.4e2 6.0} GiD_Mesh create element 58 triangle 3 {7 15 2} steel GiD_Mesh delete element {58 60}
GiD_Result create|delete|get|get_nodes <data>
To create, delete or get postprocess results.
Examples:
GiD_Result create {Result "Res Nodal 1" "Load analysis" 4 Scalar OnNodes} {1 2} {2 2} {113 2} {3 5} {112 4} GiD_Result create {Result "Res Gauss 1" "Load analysis" 4 Scalar OnGaussPoints "My Gauss"} {165 2} {2} {3} {164 5} {4} {3} GiD_Result delete {"Res Nodal 1" "Load analysis" 4}
GiD_ModifiedFileFlag set|get ?<value>?
There is a GiD internal flag to indicate that the model has changed, and must be saved before exit.
With this command it's possible to set or get this value flag.
Example:
ModifiedFileFlag set 1 ModifiedFileFlag get
GiD_MustRemeshFlag set|get ?<value>?
There is a GiD internal flag to indicate that the geometry, conditions, etc are changed,
and must re-generate the mesh before calculate.
With this command it's possible to set or get this value flag.
Example:
GID_MustRemeshFlag set 1 GID_MustRemeshFlag get
GiD_SetModelName <name>
To change the current model name.
GiD_Set <varname> ?<value>?
This command set or get GiD variables.
GiD variables can be found through the right buttons menu (see section Graphical), under the option utilities > variables.
Example:
GiD_Set CreateAlwaysNewPoint 1
drawopengl
It is possible to use directly OpenGL commands from GiD-Tcl using the command "drawopengl draw"
For example:
C/C++ use:
glBegin(GL_LINES); glVertex(x1,y1,z1); glVertex(x2,y2,z2); glEnd();
GiD-Tcl use:
drawopengl draw -begin lines drawopengl draw -vertex [list $x1 $y1 $z1] drawopengl draw -vertex [list $x2 $y2 $z2] drawopengl draw -end
The standard syntax must be changed following these rules:
- OpenGL constants: "GL" prefix and underscores character '_' must be removed. The command must be written
in lowercase.
Example:
GL_COLOR_MATERIAL -> colormaterial
- OpenGL functions: "GL" prefix must be removed and command written in lowercase. Pass parameters as list, without use parenthesis ()
Example:
glBegin(GL_LINES) -> glbegin lines
The subcommand "drawopengl draw" provides access to standard OpenGL commands, but also exists other "drawopengl" special GiD sucommands:
proc MyRedrawProcedure ... set id [drawopengl register MyRedrawProcedure]
drawopengl unregister $id
drawopengl draw -rasterpos [list $x $y] drawopengl drawtext "hello world"
drawentity -mode filled surface "1 5 6"
List of supported OpenGL functions:
accum
alphafunc
begin
blendfunc
call
calllist
clear
clearaccum
clearcolor
cleardepth
clearstencil
clipplane
color
colormask
colormaterial
copypixels
cullface
deletelists
depthfunc
depthmask
dfactorBlendTable
disable
drawbuffer
drawpixels
edgeflag
enable
end
endlist
evalcoord1
evalcoord2
evalmesh1
evalmesh2
finish
flush
fog
frontface
frustum
genlists
hint
hintModeTable
initnames
light
lightmodel
linestipple
linewidth
loadidentity
loadmatrix
loadname
lookat
map1
map2
mapgrid1
mapgrid2
material
matrixmode
modeColorMatTable
multmatrix
newlist
newListTable
normal
opStencilTable
opStencilTable
ortho
perspective
pickmatrix
pixeltransfer
pixelzoom
pointsize
polygonmode
popattrib
popmatrix
popname
pushattrib
pushmatrix
pushname
rasterpos
readbuffer
readpixels
rect
rendermode
rotate
scale
scissor
selectbuffer
shademodel
stencilfunc
stencilmask
stencilop
texcoord
texenv
texgen
teximage1d
teximage2d
texparameter
translate
vertex
viewport
List of special non OpenGL standard functions:
getselection
List of supported OpenGL constants:
accum
accumbuffer
accumbufferbit
add
alphatest
always
allattrib
allattribbits
ambient
ambientanddiffuse
autonormal
aux0
aux1
aux2
aux3
back
backleft
backright
blend
bluebias
bluescale
ccw
clamp
clipplane0
clipplane1
clipplane2
clipplane3
clipplane4
clipplane5
colorbuffer
colorbufferbit
colorindex
colormaterial
compile
compileandexecute
constantattenuation
cullface
current
currentbit
cw
decal
decr
depthbuffer
depthbufferbit
depthtest
diffuse
dither
dstalpha
dstcolor
enable
enablebit
emission
equal
eval
evalbit
exp
exp2
eyelinear
eyeplane
feedback
fill
flat
fog
fogbit
fogcolor
fogdensity
fogend
fogmode
fogstart
front
frontandback
frontleft
frontright
gequal
greater
greenbias
greenscale
hint
hintbit
incr
invert
keep
left
lequal
less
light0
light1
light2
light3
light4
light5
light6
light7
lighting
lightingbit
lightmodelambient
lightmodellocalviewer
lightmodeltwoside
line
linebit
linear
linearattenuation
lineloop
lines
linesmooth
linestipple
linestrip
list
listbit
load
map1color4
map1normal
map1texturecoord1
map1texturecoord2
map1texturecoord3
map1texturecoord4
map1vertex3
map1vertex4
map2color4
map2normal
map2texturecoord1
map2texturecoord2
map2texturecoord3
map2texturecoord4
map2vertex3
map2vertex4
modelview
modulate
mult
nearest
never
none
normalize
notequal
objectlinear
objectplane
one
oneminusdstalpha
oneminusdstcolor
oneminussrcalpha
oneminussrccolor
packalignment
packlsbfirst
packrowlength
packskippixels
packskiprows
packswapbytes
pixelmode
pixelmodebit
point
pointbit
points
polygon
polygonbit
polygonstipple
polygonstipplebit
position
projection
q
quadraticattenuation
quads
quadstrip
r
redbias
redscale
render
repeat
replace
return
right
s
scissor
scissorbit
select
shininess
smooth
specular
spheremap
spotcutoff
spotdirecion
spotexponent
srcalpha
srcalphasaturate
srccolor
stenciltest
stencilbuffer
stencilbufferbit
t
texture
texture1d
texture2d
texturebit
texturebordercolor
textureenv
textureenvcolor
textureenvmode
texturegenmode
texturegens
texturegent
texturemagfilter
textureminfilter
texturewraps
texturewrapt
transform
transformbit
triangles
trianglefan
trianglestrip
unpackalignment
unpacklsbfirst
unpackrowlength
unpackskippixels
unpackskiprows
unpackswapbytes
viewport
viewportbit
zero
Can read the description of the standard OpenGL functions in an OpenGL manual.
Managing menus |
GiD offers some functions to change the GiD menus. With these functions it is possible to add new menus or to change the existing ones. If you are creating a problem type, these functions should be called from the InitGIDProject
or InitGIDPostProcess
functions (see section TCL/TK EXTENSION).
Note: Menus and option menus are identified by its name.
Note: It is not necessary to restore the menus when leaving the problem type, GiD already does it.
The Tcl functions are:
new_menu_name
: name of the new menu.
prepost
can have these values:"PRE"
to create the menu only in the preprocess"POST"
to create the menu only in the postprocess"PREPOST"
to create the menu in the pre and postprocess
menu_name
: name of the menu to remove.
prepost
can have these values:"PRE"
to delete the menu only in the preprocess"POST"
to delete the menu only in the postprocess"PREPOST"
to delete the menu in the pre and postprocess
insert
argument is given, the new menu option is inserted.
menu_name
: name of the menu where you want to insert the new option.
option_name
: name of the new option you want to insert. If option_name
is "---"
, then , a separator line is inserted in the menu. If you want to insert an option to a submenu, you have to specify the path with ">". Geometry>Create>MyOption
position
: position in the menu where the option has to be inserted. Note that positions start at 0, and separator lines also count.
command
: is the command called when the menu option is selected.
prepost
: this argument can have the following values: "PRE"
to insert the option in the preprocess menus "POST"
to insert the option in the postprocess menus "PREPOST"
to insert the option in the pre and postprocess menus
insert/replace
: if this argument is insert
the new option is inserted. If the argument is replace
the new option replaces the option of the given position. This argument is optional, and by default the new option replaces the existing one. option_name
: name of the new option you want to insert. If option_name
is "---"
,
then , a separator line is inserted in the menu.
command
: is the command called when the menu option is selected.
position
: position in the menu where the option has to be inserted: an integer
or end
(default) to indicate the last position in the menu. Note that positions
start at 0, and separator lines also count.
accelerator
: Acceleration key combination (default "").
menu_name
: name of the menu which has the option you want to remove.
option_name
: name of the option you want to remove. If you want to remove a submenu or a submenu option, you have to specify the path with ">". Example: Geometry>Create>Point
prepost
: this argument can have the following values: "PRE"
to remove an option of the preprocess menus"POST"
to remove an option of the postprocess menus"PREPOST"
to remove an option of the pre and the postprocess menus
menu_name
and option_name
are case sensitive.CreateMenu
, InsertMenuOption
or RemoveMenuOption
, are done.
EXAMPLE: creating and modifying menus
In this example we create a new menu called "New Menu" and we modify the GiD Help menu:
The code to make these changes would be:
CreateMenu "New Menu" "PRE" InsertMenuOption "New Menu" "Option 1" 0 "Command_1" "PRE" InsertMenuOption "New Menu" "Option 2" 1 "Command_2" "PRE" InsertMenuOption "New Menu" "---" 2 "" "PRE" InsertMenuOption "New Menu" "Option 3" 3 "Command_3" "PRE" InsertMenuOption "Help" "My Help" 1 "" "PRE" "insert" InsertMenuOption "Help" "My Help>My help 1" 0 "Command_help1" "PRE" InsertMenuOption "Help" "My Help>My help 2" 1 "Command_help2" "PRE" RemoveMenuOption "Help" "Customization Help" "PRE" RemoveMenuOption "Help" "What is new ..." "PRE" RemoveMenuOption "Help" "FAQ" "PRE" UpdateMenus
EXAMPLE: removing a submenu or a submenu option
In this example we remove the option Quadrilateral
of the Meshing
menu.
To remove option Quadrilateral
:
RemoveMenuOption "Meshing" "Element type>Quadrilateral" "PRE" UpdateMenus
HTML support |
The problem type developer can take advantage of the internal HTML browser if he wants to provide an online help.
HelpWindow |
html
inside your problem type directoryproblem_type_name
is the name of your problem type with the .gid
extension (for example, cmas2d.gid
).html
folder.
It's a good idea to call the function HelpWindow "CUSTOM_HELP" "problem_type_name" using the menu functions (see section Managing menus).
EXAMPLE: Adding a customized HTML help in the Help menu for the CMAS2D problem type:
InsertMenuOption "Help" \ "Help CMAS2D" 0 {HelpWindow "CUSTOM_HELP" "cmas2d.gid"} "PREPOST" UpdateMenus
GiDCustomHelp |
From version 7.4 the problemtype developer can to take advantage of the new
help format. It is essentially the same html content, but now with and
enhancement look and structure. The procedure to show the help using the new
format is GiDCustomHelp
:
GiDCustomHelp ?args?
Where args is a list of pairs option value
. The valid options are:
"Help on <problemtype name>"
"<ProblemType dir>/html"
. Multilingual content
could be present, in such case it is assumed that there is a directory
for each language provided. If the current language is not found,
language 'en'
(for english) is tried. Finally if 'en'
is
not found the value provided to the option -dir is assumed as
the base directory for the help content.
-start html-version -start html-tutorials/tutorial_1
Structure of the help content |
Assuming we have chosen html as the base directory for the multilingual elp contents we can have the following structure:
html \__ en - English content \__ es - Spanish content
Each content will provably have a directory structure to organize the information. By default the help system build a tree resembling the directory structure of the help content. In this sense there will be an internal node for each subdirectory, finally the html documents will be the terminal nodes of the tree.
We can also provide a help.conf
configuration file in order to
provide more information about the structure of the help. In a help
file we can specify a table of contents (TocPage
), help
subdirectories (HelpDirs
) and topic index (IndexPage
).
HelpDirs |
With HelpDirs we can specify which of the subdirectories will be internal nodes of the help tree. Also we can specify label for the node and a link to load when the noded is clicked. The link is relative the node. For instance:
HelpDirs {html-version "GiD Help" "intro/intro.html"} \ {html-customization "GiD Customization"} \ {html-faq "Frequently Asked Questions"} \ {html-tutorials "GiD Tutorials" "tutorials_toc.html"} \ {html_whatsnew "Whats New"}
TocPage |
TocPage define an html page as a page describing a table of contents of the current node (current directory). We have considered two ways for specifying a table of content:
1- <UL> <LI> ... </UL> (default) 2- <DT> <DL> ... </DT>
The first is the one generated by texinfo.
For instance:
TocPage gid_toc.html TolcPage contents.ht DT
IndexPage |
If we specify by IndexPage a topic index we can take advantage of the search index. In indexPage we can provide a set of html index pages along with the structure type of the index. The type of the index could be:
1- <DIR> <LI> ... </DIR> (default) 2- <UL> <LI> ... </UL> (only one level of <UL>)
The first is the one generated by texinfo.
For instance:
IndexPage html-version/gid_18.html html-faq/faq_11.html
Custom Data Windows |
In this section the Tcl/Tk (scripted) customization of the look and feel of the
data windows is shown. The layout of the properties drawn in the
interior of any of the data windows either Conditions
,
Materials
, Interval Data
or Problem Data
can be
customized by a feature that we called TkWidget
. While the
common behaviour of two specific data windows: Conditions and
Materials, can be changed by a tcl procedure provided for that
purpose. This common behaviour include, for instance in the case of
Materials, assigning/unassigning, drawing, geometry types where to
assign materials, creating/deletening materials, etc.
TkWidget |
The problem type developer can change the way a QUESTION is displayed and if he wishes he can also change the whole contents of the window, maintaining the basic behavior of the data set, i.e. in condition window: assign, unassign, draw; in material window: create material, delete material and so on.
With the default layout for the data windows the questions are placed one after another in one column inside a container frame, the QUESTION's label in column zero and the VALUE in column one for an example see picture below.
CONDITION: Steel_section CONDTYPE: over lines CONDMESHTYPE: over body elements QUESTION: Local_Axes#LA#(-Default-,-Automatic-) VALUE: -Default- QUESTION: SteelName VALUE: IPN-80 QUESTION: SteelType VALUE: A37 END CONDITION
Default layout in data windows
The developer can override this behavior using TKWIDGET. TKWIDGET is defined as an attribute of a QUESTION and the value associated to it must be the name of Tcl procedure, normally implemented in a Tcl file of the problem type. This procedure will take care of drawing the QUESTION. A TKWIDGET may also draw the entire contents of the window and also attending some events related to the window and its data.
The prototype of a TKWIDGET procedure is as follow:
proc TKWidgetProc {event args} { switch $event { INIT { ... } SYNC { ... } DEPEND { ... } CLOSE { ... } } }
The procedure should return:
{ERROR-TYPE Description}
where
ERROR-TYPE
could be ERROR
or
WARNING
. ERROR
means that something is wrong and the
action should be aborted. If ERROR-TYPE
is WARNING
then the
action is not aborted but Description
is showed as a message.
In any case if Description
is not empty a message is showed.
The argument event
is the type of event and args
is the
list of arguments depending on the event type. The possible events
are: INIT, SYNC, CLOSE and
DEPEND. Below is a description of each event.
{frame row-var GDN STRUCT QUESTION}
: frame
is the
container frame where the widget should be placed, row-var
is
the name of the variable, used by GiD, with the current row
in the frame, GDN and STRUCT are the names of
internal variables needed to access the values of the data,
QUESTION is the QUESTION's name for which the
TKWIDGET procedure was invoked. Normally the code for this
event should initialize some variables and draw the widget.
{GDN STRUCT QUESTION}
.
lvalue
of the dependence. The
list of arguments is {GDN STRUCT QUESTION ACTION value}
where
GDN, STRUCT and QUESTION are as
before, ACTION could be SET, HIDE or
RESTORE and value is the value assigned in the dependence.
The picture below shows a fragment of the data definition file and the GUI obtained. This sample is taken from problemtype RamSeries/rambshell and in this case the TKWIDGET is used to create the whole contents of the condition windows. For a full implementation, please download the problem type and check it.
CONDITION: Steel_section CONDTYPE: over lines CONDMESHTYPE: over body elements QUESTION: Local_Axes#LA#(-Default-,-Automatic-) VALUE: -Default- QUESTION: SteelName VALUE: - QUESTION: SteelType VALUE: - TKWIDGET: SteelSections END CONDITION
Customized layout in data windows
Data Windows Behaviour |
In this subsection we explain a tcl procedure used to configure the
common behaviour of Materials
. We are working in providing a
similar functionality for Conditions
using the same interface.
GiD_DataBehaviour
controls properties of data windows for
Materials
and Conditions
(not currently
implemented). For Materials
we can modify the behaviour of
assign, draw, unassign, impexp
(import/export), new,
modify
and delete
. We can also specify the entity type list in
assign option throught the subcommands geomlist
and
meshlist
.
The syntax of the procedure is as follow:
GiD_DataBehaviour data_class name ?cmd? proplist
where,
data_class
could be: "material"
if we want to modify the behaviour of a
particular material or "materials"
if a whole book must be
modified.
name
depending on the value of data_class
the argument name
takes the value of a material's name or a book's name.
cmd
can take one of the values: show, hide, disable, geomlist
and
meshlist
.
proplist
is a list of options or entity type. When cmd
is show,
hide
or disable
then proplist
could be a subset of
{assign draw unassign impexp new modify delete}
. If
cmd
is show
it makes the option visible, if the value is
hide
then the option is not visible and when the value is
disable
then the option is visible but unavailable. When
cmd
if geomlist then then property list can take a subset of
{points lines surfaces volumes}
defining the entities that
can get the material assigned when in geometry mode, if the value of
cmd
is meshlist
then proplist
can take the value
elements
. Take into account that only elements can gets a
material assigned in mesh mode. If cmd
is not provided we
obtain as a result the corresponding state for each of the items
provided in proplist
.
Example:
GiD_DataBehaviour materials Table geomlist {surfaces volumes} GiD_DataBehaviour materials Solid hide {delete impexp}
GiD version |
Normally a problem type requires a minimum version of GiD to run. Because the problem type can be distributed or sold separately from GiD, it's important to check the GiD version before continuing with the execution of the problem type. GiD offers a function, GiDVersionCmp, which compares the version of the GiD which is currently running with a given version.
GiDVersionCmp { Version }
Returns a negative integer if Version
is greater than the
currently executed GiD version; zero if the two versions are
identical; and a positive integer if Version
is less than the
GiD version.
Note: This function will always return a -1 if the GiD version is previous to 6.1.5.
EXAMPLE
proc InitGIDProject { dir } { global GidPriv set VersionRequired "7.7.0b" set comp -1 catch { set comp [GiDVersionCmp $VersionRequired] } if { $comp < 0 } { WarnWin [= "This interface requires GiD %s or later" $VersionRequired] } }
Using EXEC in GiD |
The Tcl language has the exec
command used to invoke a sub
process. This command treats its arguments as the specification of one
or more sub processes to execute. It's possible to invoke a sub
process from GiD using this option.
Example: invoking a process in the background
exec netscape http://www.gidhome.com &
Note: In Windows, instead of &
it's necessary to put >& NUL: &
to run the process in the background. Example: exec PROGRAM_NAME >& NUL: &
Detailed example - Tcl/Tk extension creation |
Next is an example of the creation of a Tcl/Tk extension, step by
step. In this example we will create the cmas2d.tcl
file, so,
we will extend the capabilities of the cmas2d problem type. The
file cmas2d.tcl
has to be placed inside the cdmas2d problem
type directory.
Note: The cmas2d problem type calculates the center of masses
of a 2D surface. This problem type is located inside
problemtypes
, in the GiD directory.
In this example, the cmas2d.tcl
creates a window which appears
when the problem type is selected.
Window created in the cmas2d.tcl example file
This window gives information about the location, materials and conditions of the problem type. The window has two buttons: the button CONTINUE lets the users continue working with the cmas2d problem type; the button RANDOM SURFACE creates a random 2D surface in the plane XY.
Here starts the Tcl code for the example. There are three main procedures in the cmas2d.tcl
file:
proc InitGIDProject {dir } { set materials [GiD_Info materials] set conditions [GiD_Info conditions ovpnt] CreateWindow $dir $materials $conditions }This is the main procedure. It is executed when the problem type is selected. It calls the CreateWindow procedure.
proc CreateWindow {dir mat cond} { set w .gid.win_example InitWindow $w "CMAS2D.Tcl - Example tcl file" ExampleCMAS2D "" \ "" 1 frame $w.top label $w.top.title_text \ -text " Tcl window example for CMAS2D problem type " frame $w.information -relief ridge -bd 2 label $w.information.path \ -text " Problem Type path: $dir " label $w.information.materials \ -text " Available materials: $mat" label $w.information.conditions \ -text " Available conditions: $cond" frame $w.bottom button $w.bottom.start \ -text "CONTINUE" \ -height 1 -width 14 -command "destroy $w" button $w.bottom.random \ -text "RANDOM SURFACE" \ -height 1 -width 20 -command "CreateRandomSurface $w" pack $w.top.title_text -pady 10 pack $w.information.path $w.information.materials \ $w.information.conditions -side top -anchor w pack $w.bottom.start $w.bottom.random \ -side left -anchor center pack $w.top pack $w.information -expand yes -fill both pack $w.bottom -side top -padx 6 -pady 10 -ipady 2 }This procedure creates the window with information about the path, the materials and the conditions of the project. The window has two buttons: if the CONTINUE button is pressed the window is dismissed; if the RANDOM SURFACE button is pressed, it calls the CreateRandomSurface procedure.
proc CreateRandomSurface {w} { set ret [tk_dialogRAM $w.dialog "Warning!!" \ "Warning: this will create a nurbs surface in your \ current project" "" 1 "ok" "cancel"] if {$ret ==0} { Create_surface destroy $w } }This procedure is called when the RANDOM SURFACE button is pressed. Before creating the surface, a dialog asks the user to continue or to cancel the creation of the surface. If the surface has to be created, the Create_surface procedure is called. Then, the window is destroyed.
proc Create_surface {} { set a_x [expr rand()*10] set a_y [expr rand()*10] set b_x [expr $a_x + rand()*10] set b_y [expr $a_y + rand()*10] set c_x [expr $b_x + rand()*10] set c_y [expr $b_y - rand()*10] if {$a_y < $c_y} { set d_y [expr $a_y - rand()*10] set d_x [expr $a_x + rand()*10] } else { set d_y [expr $c_y - rand()*10] set d_x [expr $c_x - rand()*10] } GiD_Process escape escape escape escape GiD_Process geometry create line \ $a_x,$a_y,0.000000tol0.176991 \ $b_x,$b_y,0.000000tol0.176991 \ $c_x,$c_y,0.000000tol0.176991 \ $d_x,$d_y,0.000000tol0.176991 \ close GiD_Process escape escape escape escape GiD_Process geometry create NurbsSurface Automatic 4 escape GiD_Process zoom frame escape escape escape escape }
Go to the first, previous, next, last section, table of contents.