Control functions

GiD offers the following Tcl functions:

Process function

GiD_Process command_1 command_2 ...

This is a simple function, but a very powerful one. It is used to enter commands directly inside the central event manager. The commands have the same form as those typed in the command line within GiD.

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.

You can obtain the exact commands that GiD needs by checking the Right buttons menu (Utilities -> Tools -> Toolbars). It is also possible to save a batch file (Utilities -> Preferences) where the commands used during the GiD session can be checked.

Here is a simple example to create one line:

GiD_Process Mescape Geometry Create Line 0,0,0 10,0,0 escape

Note : Mescape is a multiple 'escape' command, to go to the top of the commands tree.

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:

This command returns a list of the materials in the project.

These options are also available:

Examples:

in: GiD_Info materials

out: "Air Steel Aluminium Concrete Water Sand"

in: GiD_Info materials Steel

out: "1 Density 7850"

This command returns a list of the conditions in the project. One of the arguments ovpnt, ovline, ovsurf, ovvol must be given to indicate the type of condition required, respectively, conditions over points, lines, surfaces or volumes.

Instead of ovpnt, ovline, ovsurf, ovvol , the following options are also available:

Examples:

in: GiD_Info conditions ovpnt

out: "Point-Weight Point-Load"

in: GiD_Info conditions Point-Weight

out: "ovpnt 1 Weight 0"

in: GiD_Info conditions Point-Weight geometry

out: "E 1 - 2334 , E 2 - 2334 , E 3 - 343"

in: GiD_Info Conditions -localaxes Concrete_rec_section mesh 2

out: {E 2 - {4.7123889803846897 1.5707963267948966 0.0} N-m 0.3 0.3 HA-25}

This command returns a list of the layers in the project.These options are also available:

Example:

in: GiD_Info back_layers

out: Layer2_*back*

For elements it is possible to specify -elementtype <elementtype> to get only this kind of elements.

-higherentity <num> Allow to get only entities with this amount of higherentities.

Examples:

in: GiD_Info layers

out: "layer1 layer2 layer_aux"

in: GiD_Info layers -on

out: "layer1 layer2"

in: GiD_Info layers -entities lines layer2

out: "6 7 8 9"

This command returns the information entered in the Problem Data window (see Problem and intervals data file (.prb) ).

The following options are available:

This command returns a list of the interval data in the project (see Problem and intervals data file (.prb) ). The following options are available:

This command returns information about the project. More precisely, it returns a list with:

It is possible to ask for a single item only rather than the whole list, with <item> equal to: ProblemType | ModelName | AreChanges | LayerToUse | ViewMode | Quadratic | RenderMode | ExistPost | Debug | TmpDirectory | MustReMesh | LastElementSize | BackgroundFilename | RequireMeshSize | RecommendedMeshSize

Example:

in: GiD_Info Project

out: "cmas2d e:\models\car_model 1 layer3 MESHUSE 0 normal YESPOST nodebug C:\TEMP\gid2 0 1.4"

in: GiD_Info Project ModelName

out: "e:\models\car_model"

This command gives the user information about the geometry in the project. For each entity, there are two possibilities:

This command gives the user information about the selected mesh in the project.

It returns a 1 followed by a list with all types of element used in the mesh.

Examples:

in: GiD_Info Mesh

out: "1 Tetrahedra Triangle"

in: GiD_Info Mesh MaxNumNodes

out: "1623"

This command returns the coordinates (x,y,z) of a given point or node.

This command returns the value of the variable indicated. GiD variables can be found in the Right buttons menu (see UTILITIES>Tools from Reference Manual), under the option Utilities -> Variables.

Returns a list with all the user defined local axes.

info localaxes <name> returns the parameters (three euler angles and the center) that define the local axes called <name>.

info localaxes <name> -localaxesmat instead of returning the three euler angles, it returns the nine numbers that define the transformation matrix of a vector from the local axes system to the global one.

This command returns a list (Left, Right, Bottom, Top, Near, Far, Ext) of the limits of the geometry in the project.

In perspective mode near and far have the perspective distance substracted.

This command returns which perspective factor is currently being used in the project.

This command returns the coordinates (x,y,z) of the center of rotation.

This command returns a list of numbers. These naturals are the Y relative values of the graph shown in the option Meshing -> Mesh quality (see MESH>Mesh Quality from Reference Manual) and two additional real numbers with the minimum and maximum limits.

This command has the following arguments:

if min_value and max_value are set to 0 then limits will be automatically set to the minimum and maximum of the mesh

Example:

in: GiD_Info MeshQuality MinAngle Triangle 20 60 4

out: "13 34 23 0 20.0 60.0"

This command returns YES if the user is in the GiD postprocess, and NO, if not.

This command returns information about the GiD postprocess. The following options are available:

This command returns the value of the Import Tolerance used in the project. This value is defined in the Preferences window under Import .

This command returns the default background color in RGB. The format is three 8 bit numbers separated by #. Example: 255#255#255 would be white.

This command returns a list with general information about the current GiD project.

PreStatus ask for the information of preprocess

PostStatus ask for the information of postprocess

Status return the infomation of pre or postprocess depending of where are now, in pre or post mode.

Example:

in: GiD_Info list_entities PreStatus

out:

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%

This command returns information about entities.

It has the following arguments:

Using "list_entities Results" you must also specify <analysis_name> <step> <result_name> <indexes>With the option -more, more information is returned about the entity. The -more option used with lines returns the length of the line, its radius (arcs), and the list of surfaces which are higher entities of that line; used with elements it returns the type of element, its number of nodes and its volume.

Example 1:

in: GiD_Info list_entities Points 2 1

out:

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

Example 2:

in: GiD_Info list_entities lines layer:car_lines

out:

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

Example 3 (using -more ):

in: GiD_Info list_entities -more Lines 2

out:

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

This command returns geometric information (coordinates, derivates, etc.) about parametric lines or surfaces.

For lines it has the following syntax:

GiD_Info parametric line entity_id coord | deriv_t | deriv_tt | t_fromcoord | t_fromrelativelength t | x y z

And for surfaces:

GiD_Info parametric surface entity_id coord | deriv_u | deriv_v | deriv_uu | deriv_vv | deriv_uv | normal | uv_fromcoord | maincurvatures u v | x y z

The result for each argument is:

v1x v1y v1z : first main curvature vector direction (normalized)

v2x v2y v2z : second main curvature vector direction (normalized)

c1 c2: main curvature values

Note: The vector derivatives are not normalized.

Example:

in: GiD_Info parametric line 26 deriv_t 0.25

out: 8.060864 -1.463980 0.000000

This command returns some specialized entities check.

For lines it has the following syntax:

GiD_Info check line <entity_id> isclosed

For surfaces:

GiD_Info check surface <entity_id> isclosed | isdegeneratedboundary | selfintersection

And for volumes:

GiD_Info check volume <entity_id> orientation | boundaryclose

The result for each argument is:

Example:

in: GiD_Info check volume 5 orientation

out: 2 {4 38}

This command returns properties of the selected entities. It returns the length if entities are lines, area if surfaces, volume if volumes, or the center of gravity if entities are nodes or elements. It has the following arguments:

Example:

in: GiD_Info ListMassProperties Lines 13 15

out:

LINES

n. Length

13 9.876855

15 9.913899

Selected 2 figures

________________________

Total Length=19.790754

This command returns the absolute path to the current problem type.

This command returns the GiD version number. For example 9.0

This command returns the current view parameters. Something like:

{x -13.41030216217041 13.41030216217041} {y 10.724431991577148 -10.724431991577148} {z -30.0 30.0} {e 10.0} {v 0.0 0.0 0.0} {r 1.0}

{m 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0} {c 0.0 0.0 0.0} {pd 0.0} {pno 0.0} {pfo 0.0} {pf 4.0} {pv 0.0} {NowUse 0}

{DrawingType 0} {LightVector 90.0 90.0 150.0 0.0}

See VIEW>View entry>Save/Read View of Reference Manual for a brief explanation of this parameters

GiD_Info IsPointInside ?-tolerance <tol>? Line|Surface|Volume <num> {<x> <y> <z>}

This commands returns 1 if the point {x y z} is inside the specified volume/surface/curve, or 0 if lies outside.

Special functions

Geometry

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:

  • <num>|append : <num> is the entity identifier (integer > 0). You can use the word 'append' to set a new number automatically.
  • <data> : is all the geometric definition data (create ) or a selection specification (delete , get or list ):

create: to make new geometric entities

  • GiD_Geometry create volume <num> | append layer numsurfaces {surface1 verso1} ... ?contactvolume <transformation_matrix>?

for contactvolume is necessary to specify the <transformation_matrix> : a vector of 16 reals representing a 4x4 transformation matrix that maps surface1 into surface2

  • GiD_Geometry create surface <num> | append plsurface | nurbssurface | coonsurface | meshsurface | contactsurface layer numlines ?<nurbs_data>? {line1 verso1} ... <geometrical_data>

<nurbs_data> must be provided only for NURBS surfaces and are this variables:

u_degree v_degree numpoints_u numpoints_v istrimmed isrational

<geometrical data> depends of each entity type (see get command)

  • GiD_Geometry create line <num>|append nurbsline layer inipoint endpoint degree numpoints isrational {point1_x point1_y point1_z ?point1_w?} ... knot_1 ...

Instead the NURBS parameters is possible to create a curve that interpolates a list of points (also tangents at start and end can be specified)

GiD_Geometry create line <num> | append nurbsline layer inipoint endpoint -interpolate numpoints {p1_x p1_y p1_z} ... {pn_x pn_y pn_z} ?-tangents {t0_x t0_y t0_z} {t1_x t1_y t1_z}?

  • GiD_Geometry create line <num>|append stline layer inipoint endpoint
  • GiD_Geometry create point <num>|append layer point_x point_y point_z

delete: to erase model entities

  • GiD_Geometry delete point|line|surface|volume <args> with <args>: num numa:numb numa: layer:layer_name

get: to obtain all the geometrical data to define a single entity

  • GiD_Geometry get point|line|surface|volume <args> with <args>: num

  • GiD_Geometry get point will return:

<layer> <geometrical data>

<layer> is the layer name

<geometrical data> the coordinates x y z

  • GiD_Geometry get line will return:

<type> <layer> <p1> <p2> <geometrical data>

<type> can be: stline, nurbsline, arcline, polyline

<layer> is the layer name

<p1> identifier of start point

<p2> identifier of end point

<geometrical data> depends of each entity type

stline: nothing

nurbsline: <d> <n> <rat> {x y z ?w?}1 ... {x y z ?w?}n <k0> ... <kn+d>

<d>degree

<n>number of control points

<rat> 1 if rational, else 0

{xi yi zi ?wi?} control points coordinates. If rational wi is the weight

<ki> knots

arcline: {xc yc} <r> <sa> <ea> {m11 ... m44}

{xc yc} 2D center

<r> radius

<sa> start angle (rad)

<ea> end angle (rad)

{m11 ... m44} transformation 4x4 matrix (the identity for a 2D case)

m11 ...m33 is a rotation 3x3 matrix

m14 ...m34 is a translation 3x1 vector

m44 is an scale factor

m41 ... m43 must be 0

polyline: not implemented

  • GiD_Geometry get surface will return:

<type> <layer> <nl> ?<nurbs_data>? {l1 o1} ... {lnl onl} <geometrical data>

<type> can be: nurbssurface plsurface coonsurface meshsurface

<layer> is the layer name

<nl> number of boundary lines (including holes)

<nurbs_data> only for NURBS surfaces (<du> <dv> <nu> <nv> <istrimmed> <isrational>)

{li oi} identifier of line and its orientation for the surface (1 if opposite to the line advance, 0 else)

Note: turning left of a line with orientation 0 we go inside the surface.

<geometrical data> depends of each entity type

plsurface: nothing

coonsurface: nothing

nurbssurface {x y z ?w?}1 ... {x y z ?w?}nu xnv <ku0 > ... <kunu+du > <kv0 > ... <kvnv+dv >

<du> <dv>degree in u, v direction

<nu> <nv>number of control points in each direction

<ratu> <ratv> 1 if rational, 0 else

{xi yi zi ?wi ?} control points coordinates. If rational wi is the weight

<kui > <kvi > knots in each direction

meshsurface: nn ne nnode {x1 y1 z1 ... xnn ynn znn } {a1 b1 c1 ?d1 ? ... ane bne cne ?dne ?}

nn: number of nodes

ne: number or elements (triangles or quadrilaterals)

nnode: number of nodes by element: 3 or 4

xi yi zi : coordinates

ai bi ci di : connectivities (di only for quadrilaterals)

  • GiD_Geometry get volume will return:

<layer> <ns> {s1 o1} ... {snl onl}

<layer> is the layer name

<ns> number of boundary surfaces (including holes)

{si oi} identifier of surface and its orientation for the volume (1 if opposite to the surface normal, 0 else)

Note: the normal of a surface with orientation 0 points inside the volume

list: to get a list of entity identifiers of a range or inside some layer

  • GiD_Geometry list point | line | surface | volume <args> with <args>: num numa:numb numa: layer:layer_name

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

Mesh

GiD_Mesh create|delete|edit|get node|element <num>|append <elemtype> <nnode> <N1 ... Nnnode> <radius> <nx ny nz> ?<matname>? | <x y z>

To create, delete, modify or know information about mesh nodes or elements of the preprocess:

  • <num>|append : <num> is the identifier (integer > 0) for the node or element. You can use the word 'append' to set a new number automatically. The number of the created, deleted or modified entity is returned as the result. When deleting, it is possible to use a list of entities;
  • <elemtype> : must be one of "point | linear | triangle | quadrilateral | tetrahedra | hexahedra | prism | pyramid | sphere | circle"
  • <nnode> is the number of nodes an element has
  • <N1 ... Nnnode> is a Tcl list with the element connectivities
  • <radius> is the element radius, only for sphere and circle elements
  • <nx ny nz> is the normal of the plane that contain the circle
  • <matname> is the optional element material name
  • <x y z> are the node coordinates. If the z coordinate is missing, it is set to z=0.0.

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}

Data

GiD-Tcl special commands to manage materials, conditions, intervals, general data or local axes:

GiD_CreateData create|delete material ?<basename>? <name> ?<values>?

To create or delete materials:

  • <basename> this only applies to the create operation, and is the base material from which the new material is derived;
  • <name> is the name of material itself;
  • <values> is a list of all field values for the new material.

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:

  • <name> is the name of the material or condition;
  • <over> must be: points, lines, surfaces, volumes, layers, nodes, elements, body_elements, or face_elements (elements is equivalent to body_elements);
  • <newvalues> is only required for conditions. If it is set to "" then the default values are used;
  • <entities> a list of entities (it is valid to use ranges as a:b ,can use "all" to select everything, "end" to specify the last entity, layer:<layername> to select the entities in this layer) ; if <over> is face_elements then you must specify a list of "entitynumface" instead just "entity".

Example:

GiD_AssignData materials Steel Surface {2:end}

GiD_AssignData condition Point-Load Nodes {3.5 2.1 8.0} all

GiD_AssignData condition Face-Load face_elements {3.5 2.1 8.0} {15 1 18 1 20 2}

GiD_UnAssignData material|condition <name> <over> <entities> ?wherefield <fieldname> <fieldvalue>?

To unassign materials or conditions of some entities:

  • <name> is the name of the material or condition; Can use "*" to match all materials
  • <over> must be: points, lines, surfaces, volumes, layers, nodes, elements, body_elements, or face_elements (elements is equivalent to body_elements);
  • <entities> a list of entities (it is valid to use ranges as a:b ,can use "all" to select everything, "end" to specify the last entity, layer:<layername> to select the entities in this layer) ; if <over> is face_elements then you must specify a list of "entitynumface" instead just "entity".
  • wherefield <fieldname> <fieldvalue> To unassign this condition olny for the entities where the field named 'fieldname' has the value 'fieldvalue'

Example:

GiD_UnAssignData materials * Surface {end-5:end}

GiD_UnAssignData condition Point-Load Nodes layer:Layer0

GiD_UnAssignData condition Face-Load face_elements {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:

  • <name> is the material name or interval number;
  • <values> is a list of all the new field values for the material, 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 values of materials, interval data or general data:

  • <name> is the material, condition name or interval number (not necessary for gendata);
  • <question> is a field name;
  • <attribute> is the attribute name to be changed (STATE, HELP, etc.) instead of the field value;
  • <value> is the new field or attribute value.

Example:

GiD_AccessValue set gendat Solver Direct

GiD_IntervalData <mode> <number>|?copyconditions?

To create, delete or set interval data;

  • <mode> must be 'create', 'delete' or 'set';
  • <number> is the interval number (integer >=1). Create returns the number of the newly created interval and can optionally use 'copyconditions' to copy to the new interval the conditions of the current one.

For set mode, if <number> is not supplied, the current interval number is returned.

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:

  • <mode> : must be one of "create|delete|edit|exists", which correspond to the operations: create, delete, edit or exists;
  • <name> : is the name of local axes to be created or deleted;
  • <type> : must be one of "rectangular|cylindrical|spherical C_XZ_Z|C_XY_X". Currently, GiD only supports rectangular axes. C_XZ_Z is an optional word to specify one point over the XZ plane and another over the Z axis (default). C_XY_X is an optional word to specify one point over the XY plane and another over the X axis;
  • <Cx Cy Cz> is a Tcl list with the real coordinates of the local axes origin;
  • <PAxex PAxey PAxez> is a Tcl list with the coordinates of a point located over the Z' local axis (where Z' is positive). The coordinates must be separated by a space. If the z coordinate is missing, it is set to z=0.0;
  • <PPlanex PPlaney PPlanez> is a Tcl list with the coordinates of a point located over the Z'X'half-plane (where X' is positive).

For the 'exists' operation, if only the <name> field is specified, 1 is returned if this name exists, and 0 if it does not. If the other values are also apecified, <name> is ignored.

The value returned is:

-1 if the global axes match;

-2 if the automatic local axes match;

-3 if the automatic alternative local axes match;

0 if it does not match with any axes;

<n> if the user-defined number <n> (n>0) local axes match.

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)

Results

GiD_Result create|delete|get|get_nodes ?-array? <data>

To create, delete or get postprocess results:

  • GiD_Result delete {Result_name result_analysis step_value} : deletes one result;
  • GiD_Result get [ -max | -min | -compmax | -compmin | -info -array] {Result_name result_analysis step_value} : retrieves the results value list of the specified result; or if one of the -max , -min , -compmax , -compmin , or -info flags was specified: the minimum/maximum value of the result, every minimum/maximum of the components of the result, or the header information of the result (with type and location) is retrieved, respectively;
  • GiD_Result get_nodes: returns a list of nodes and their coordinates.

-array flag can be specified, for create and get subcommands, to use list of vectors to handle the information in a more efficient way

Examples:

GiD_Result create -array {Result "MyVecNodal" "Load analysis" 10 Vector OnNodes} {ComponentNames "Vx" "Vy" "Vz" "|velocity|"} {{1 3} {{2.0e-1 -3.5e-1} {2.0e-1 4.5e-1} {0.4 -2.1}}}

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 get {"Res Nodal 1" "Load analysis" 4}

GiD_Result delete {"Res Nodal 1" "Load analysis" 4}

The names of the components of the result can also be retrieved and specified:

GiD_Result create {Result "Res Nodal 2" "Load analysis" 4 Vector OnNodes} {ComponentNames "x comp" "y comp" "z comp" "modulus"} {1 2 3 4 6} {2 2 8 3 -6}

OpenGL

GiD_OpenGL

It is possible to use OpenGL commands directly from GiD-Tcl by using the command "GiD_OpenGL draw". For example, for C/C++ use:

glBegin(GL_LINES);

glVertex(x1,y1,z1);

glVertex(x2,y2,z2);

glEnd();

for GiD-Tcl use:

GiD_OpenGL draw -begin lines

GiD_OpenGL draw -vertex [list $x1 $y1 $z1]

GiD_OpenGL draw -vertex [list $x2 $y2 $z2]

GiD_OpenGL draw -end

The standard syntax must be changed according to these rules: - OpenGL constants: "GL" prefix and underscore character '_' must be removed; the command must be written in lowercase.

Example:

GL_COLOR_MATERIAL -> colormaterial

- OpenGL functions: "GL" prefix must be removed and the command written in lowercase. Pass parameters as list, without using parentheses ()

Example:

glBegin(GL_LINES) -> glbegin lines

The subcommand "GiD_OpenGL draw" provides access to standard OpenGL commands, but other "GiD_OpenGL" special GiD subcommands also exist:

  • register <tclfunc> Register a Tcl procedure to be invoked automatically when redrawing the scene. It returns a handle to unregister.

Example:

proc MyRedrawProcedure { } { ...body... }

set id [GiD_OpenGL register MyRedrawProcedure]

  • unregister <handle> Unregister a procedure previously registered with register .

Example:

GiD_OpenGL unregister $id

  • registercondition <tclfunc> <cond> Register a Tcl procedure to be invoked automatically when redrawing the specified condition. It returns a handle to unregister.
  • unregistercondition <cond> Unregister a procedure previously registered with registercondition .

  • draw <-cmd args -cmd args> This is the most important subcommand, it calls standard OpenGL commands. See the list of supported OpenGL functions.

  • drawtext <text> Draw a text more easily than using standard OpenGL commands (draw in the current 2D location, see rasterpos OpenGL command).

Example:

GiD_OpenGL draw -rasterpos [list $x $y $z]

GiD_OpenGL drawtext "hello world"

  • font push <font_name font_size> | pop | measure <text> | current | metrics ?-ascent|-descent|-linespace|-fixed?

push sets the current OpenGL font, pop restores the previous one

measure <text> returns the amount of space in pixels to display this <text>

current returns a list with the current font name and size

metrics returns a list with current font metrics information: -ascent -descent and -linespace in pixels, -fixed is 1 if all characters have equal size

Example:

GiD_OpenGL font push {"Times New Roman" 18}

set with [GiD_OpenGL measure "hello world"]

GiD_OpenGL drawtext "hello world"

GiD_OpenGL pop

  • drawentity ?-mode normal | filled? point | line | surface | volume | node | element | dimension <id list> To draw an internal GiD preprocess entity.

Example:

GiD_OpenGL drawentity -mode filled surface "1 5 6"

  • project <x y z> Given three world coordinates, this returns the corresponding three window coordinates.

  • unproject <x y z> Given three window coordinates, this returns the corresponding three world coordinates.

  • doscrzoffset <boolean> Special trick to avoid the lines on surfaces hidden by the surfaces.

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 polygonoffsetfill 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

You can find more information about standard OpenGL functions in a guide to OpenGL.

Other

GiD_Set <varname> ?<value>?

This command is used to set or get GiD variables. GiD variables can be found through the Right buttons menu under the option Utilities -> Variables:

  • <varname> is the name of the variable;
  • <value> if this is omitted, the current variable value is returned (analogous with 'GiD_Info variables <varname>').

Example:

GiD_Set CreateAlwaysNewPoint 1

GiD_SetModelName <name>

To change the current model name.

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 is possible to set or get this flag value:

  • <value> is only required for set : must be 0 (false), or 1 (true).

Example:

GiD_ModifiedFileFlag set 1

GiD_ModifiedFileFlag get

GiD_MustRemeshFlag set|get ?<value>?

There is a GiD internal flag to indicate that the geometry, conditions, etc. have changed, and that the mesh must be re-generated before calculations are performed.

With this command it is possible to set or get this flag value:

  • <value> is only required for set : must be 0 (false), or 1 (true).

Example:

GiD_MustRemeshFlag set 1

GiD_MustRemeshFlag get

GiD_BackgroundImage get|set show|filename|location <values>

This command allow to get and set the background image properties

Valid set values are:

  • show : 1 or 0
  • filename :

the full filename of some valid GiD image format to be used as background image

or "", to release the current image

  • location :

'fill' to fill the whole screen,

or six floating values for a real size image, to set the origin and x,y local axes: ox oy ix iy jx jy

Some special commands exist to control the redraw and wait state of GiD:

.central.s disable graphics 'value' The value 0/1 Enable/Disable Graphics (GiD does not 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 disable writebatch 'value' The value 0/1 Enable/Disable writting the batch file that records the commands send to be processed.

.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_Redraw

$w conf -cursor ""

.central.s waitstate 0

Note: It is recommended for a Tcl developer to use the more 'user-friendly' procedures defined inside the file 'dev_kit.tcl' (located in the \scripts directory). For example, to disable and enable redraws, you can use:

::GidUtils::DisableGraphics

::GidUtils::EnableGraphics

GiD_Thumbnail get [ width height ]

returns the byte stream of an downscaled view of the graphical window. The image is a downscaled from the current size to width x height. The parameters widht and height are optinal and by default the view is scaled to 192x144. The result of this command can be directly used by the Tk image command, like this:

label .l -image [ image create photo -data [ GiD_Thumbnail get]]

write_calc_data init | end | puts | coordinates | all_connectivities | connectivities | nodes | elements | has_elements

This is a procedure to aid to write the calculation file from tcl as alternative as the classical .bas template

  • init <filename> To open the calculation file
  • end To close the calculation file
  • puts ?-nonewline? <string> Print the string in the calculation file. -nonewline avoid the carriage return.
  • coordinates ?-count? <format> Print <num> <x> <y> <z> for each node of the mesh.

Format must be a "C-like" format for an integer an three doubles.

If -count is specified then only return the number of entities, without print.

  • all_connectivities ?-elemtype <etype>? ?-count? <format>

Print the element number and its connectivities for each element of type <etype> of the mesh (all types if -elemtype is not set)

<etype> can be: Linear | Triangle | Quadrilateral | Tetrahedra | Hexahedra | Prism | Point | Pyramid | Sphere

if -count is specified then only return the number of entities, without print.

  • connectivities|nodes | elements | has_elements ?-elemtype <etype>? ?-localaxes <groupsLADict>? ?-elements_faces all | elements | faces? ?-number_ranges <NRDict>? ?-count? <groupsDict>

To get entities information related to groups: connectivities, nodes ,elements, of if exists some element of the specified group

<etype> can be: Linear | Triangle | Quadrilateral | Tetrahedra | Hexahedra | Prism | Point | Pyramid | Sphere

<groupsLADict> is a dictionary (list of pairs key value) of local axes, with key=LA_name and value=format

-elements_faces can be set to specify any type, body elements or face elements

<NRDict> is a dictionary of number of ranges

<groupsDict> is a dictionary (key=group value=format)

if -count is specified then only return the number of entities, without print.