This is gid.info, produced by Makeinfo version 3.12h from gid.texinfo.

   This is the GiD manual

   Copyright 1997-2002 CIMNE


File: gid.info,  Node: TCL-TK extension,  Next: Index,  Prev: POSTPROCESS DATA FILES,  Up: Top

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.

   The structure of `problem_type_name.tcl' is composed by seven
possible procedures (the syntax corresponds to TCL-language):

     proc InitGIDProject { dir } {
     ...body(1)...
     }
     proc InitGIDPostProcess {} {
     ...body(2)...
     }
     proc EndGIDProject {} {
     ...body(3)...
     }
     proc EndGiDPostprocess {} {
     ...body(4)...
     }
     proc LoadGIDProject { filespd } {
     ...body(5)...
     }
     proc SaveGIDProject { filespd } {
     ...body(6)...
     }
     proc proc LoadResultsGIDPostProcess { file } {
     ...body(7)...
     }

   * InitGIDProject: will be called when the problem type is selected.
     It receives the `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.

   * InitGIDPostProcess: will be called when the postprocess starts. It
     has no arguments.

   * EndGIDProject: will be called when this project is about to be
     closed. It has no arguments.

   * EndGIDPostProcess: will be called when the user leaves postprocess
     and opens preprocess. It has no arguments.

   * LoadGIDProject: will be called when a GiD project is loaded. It
     receives the `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.

   * SaveGIDProject: will be called when the current opened file is
     saved to disk. It receives the `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.

   * LoadResultsGIDPostProcess: will be called when a results file is
     opened in the postprocess. It receives one argument, the name of
     the file being opened without its extension.

   *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); *note Specific commands::. for details.

* Menu:

* Control functions::
* Managing menus::
* HTML support::
* GiD version::
* Using EXEC in GiD::
* Detailed example - TCL-TK extension creation::


File: gid.info,  Node: Control functions,  Next: Managing menus,  Prev: TCL-TK extension,  Up: TCL-TK extension

Control functions
=================

   GiD offers the following TCL functions:

   * .central.s process command_1 command_2 ...: used to execute GiD
     commands

   * .central.s info option: used to obtain information about the
     actual GiD project

* Menu:

* process function::
* info function::


File: gid.info,  Node: process function,  Next: info function,  Prev: Control functions,  Up: Control functions

Process function
----------------

   .central.s process command_1 command_2 ...

   This is a simple function but really powerfull.  It is used to enter
commands directly inside the central event manager.  The format of the
comand 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:
     .central.s process escape escape escape escape \
             geometry create line 0,0,0 10,0,0 escape


File: gid.info,  Node: info function,  Prev: process function,  Up: Control functions

Info function
-------------

   .central.s info option

   This function provides any information about GiD, the current data or
the state of any task inside the aplication. Depending on the arguments
introduced after the `.central.s info' sentence, GiD will output
different information:

   * .central.s info materials
     This command returns a list of the materials of the project.

     Also these options are avalaible:
        - ["material_name"]: If a material name is given, its
          properties are returned. If the material name is given it's
          also possible to add the option [OTHERFIELDS] to get the
          fields of that material, or the option [BOOK], to get the
          book of that material.

        - [BOOKS]: If this option is given, a list of the material
          books of the project is returned.

          Examples:
          in:  `.central.s info materials'
          out: `"Air Steel Aluminium Concrete Water Sand"'
          in:  `.central.s info materials Steel'
          out: `"1 Density 7850"'

   * .central.s info conditions ovpnt / ovline / ovsurf / ovvol
     This command returns a list of the conditions in the project.
     Argument ovpnt, ovline, ovsurf, ovvol must be given to indicate
     the type of condition: condition over points, lines, surfaces or
     volumes.

     Instead of ovpnt, ovline, ovsurf, ovvol, the following options are
     also avalaible:
        - ["condition_name"]: if a condition name is given, the command
          returns the properties of that condition. If the condition
          name is given, it's also possible to add the option [mesh] or
          [geometry], and all mesh or geometry entities that have this
          condition assigned, will be returned. Adding the number id of
          an entity ( ["entity_id"] ) after the options [mesh] or
          [geometry], the command returns the value of the condition
          assigned to that entity.
          Other options avalaible if the condition name is given are
          [OTHERFIELD], to get the fields of that condition, and
          [BOOK], to get the book of the condition.

        - [BOOKS]: If this option is given, a list of the condition
          books of the project is returned.  Examples:
          in:  `.central.s info conditions ovpnt'
          out: `"Point-Weight"'
          in:  `.central.s info conditions Point-Weight'
          out: `"ovpnt 1 Weight 0"'
          in:  `.central.s info conditions Point-Weight geometry'
          out: `"E 1 - 2334 , E 2 - 2334 , E 3 - 343"'

   * .central.s info layers
     This command returns a list of the layers of the project.

     Also these options are avalaible:
        - ["layer_name"]: If a layer name is given, the command returns
          the properties of that layer.

        - [-on]: returns a list of the visible layers.

        - [-off]: returns a list of the hidden layers.

        - [-bbox[-use geometry|mesh] ]: layer_name_1 layer_name_2 ...]:
          returns two coordinates (x1,y1,z1,x2,y2,z2) which define the
          bounding box of the entities that belong to the list of
          layers. If the option [-use geometry|mesh] is used, the
          command returns the bounding box of the geometry or the
          bounding box of the mesh. If the list of layers is empty, the
          maximum bounding box is returned.

        - [-entities]: One of the following arguments must be given:
          nodes, elements, points, lines, surfaces or volumes.A layer
          name must also be given. The command will return the nodes,
          elements, points, lines surfaces or volumes of that layer.

          Examples:
          in:  `.central.s info layers'
          out: `"layer1 layer2 layer_aux"'
          in:  `.central.s info layers -on'
          out: `"layer1 layer2"'
          in:  `.central.s info layers -entities lines layer2'
          out: `"6 7 8 9"'

   * .central.s info gendata
     This command returns the information entered in the Problem Data
     window (*note Problem and intervals data file::.).
     The following options are avalaible:
        - [OTHERFIELDS]: it is possible to add this option to get the
          additional fields of the Problem Data window.

        - [BOOKS]: If this option is given, a list of the Problem Data
          books of the project is returned.
          Example:
          in:  `.central.s gendata'
          out: `"2 Unit_System#CB#(SI,CGS,User) SI Title M_title"'

   * .central.s info intvdata
     This command returns a list of the interval data in the project
     (*note Problem and intervals data file::.).
     The following options are avalaible:
        - [OTHERFIELDS]: it is possible to add this option to get the
          additional fields of the Interval Data window.

        - [BOOKS]: If this option is given, a list of the Interval Data
          books of the project is returned.
        - [NUM]: if this option is given, a list of two naturals is
          returned. The first element of the list is the current
          interval and the second element is the total number of
          intervals.

   * .central.s info Project
     This command returns information about the project. More
     precisely, it is returned a list with:
        * Problem type name.

        * Current example name.

        * 'There are changes' flag.

        * Current layer.

        * Active part (GEOMETRYUSE,MESHUSE,POSTUSE or GRAFUSE).

        * Quadratic problem flag.

        * Drawing type (normal,polygons,render,postprocess).

        * NOPOST or YESPOST

        * debug or nodebug

        * GiD temporary directory.

        * Geometry changes since the mesh was created (0 or 1).

        * Last size of element used for meshing (`NONE' if there's no
          mesh).

          Example:
          in:  `.central.s Project'
          out: `"cmas2d e:\models\car_model 1 layer3 MESHUSE 0 normal
          YESPOST nodebug C:\TEMP\gid2 0 1.4"'

   * .central.s info Mesh
     This command gives to 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.
     The following two options are avalaible:
        - [MaxNumElements]: returns the total number of elements of the
          mesh.

        - [MaxNumNodes]: returns the total number of nodes of the mesh.

          Examples:
          in:  `.central.s info Mesh'
          out: `"1 Tetrahedra Triangle"'
          in:  `.central.s info Mesh MaxNumNodes'
          out: `"1623"'

   * .central.s info Coordinates point_id/node_id [geometry|mesh]
     This command returns the coordinates (x,y,z) of the given point or
     node.

   * .central.s info variables "variable_name"
     This command returns the value of the variable indicated. GiD
     variables can be found through the right buttons menu (*note
     Graphical::.), under the option utilities > variables.

   * .central.s info localaxes
     This command returns a list with all the user defined local axes.

   * .central.s info ortholimits
     This command returns a list of the limits of the geometry in the
     project.

   * .central.s info perspectivefactor
     This command returns which perspective factor is being currently
     used in the project.

   * .central.s info graphcenter
     This command returns the coordinates (x,y,z) of the center of
     rotation.

   * .central.s info MeshQuality
     This command returns a list of numbers. These naturals are the Y
     relative values of the graph showed in the option Meshing > Mesh
     quality (*note Mesh quality::.).

     This command has the following arguments:
        - MinAngle/MaxAngle: quality criteria.
        - Linear/Triangle/Tetrahedra/QuadrilateralHexahedra/Prisma:
          type of element
        - "min_degrees": number of minimum degrees accepted.
        - "max_degrees": number of maximum degrees accepted.
        - "num_divisions": number of divisions.

          Example:
          in:  `.central.s info MeshQuality MinAngle Triangle 20 60 4'
          out: `"13 34 23 0"'

   * .central.s info postprocess arewein
     This command returns `YES' if the user is in the GiD postprocess,
     and `NO', if the user is not.

   * .central.s info postprocess get
     This command returns information about the GiD postprocess. The
     following options are avalaible:
        - all_volumes: returns a list of all volumes.

        - all_surfaces: returns a list of all surfaces.

        - all_cuts: returns a list of all cuts.

        - all_graphs: returns a list of all graphs.

        - all_volumes_colors: returns a list of the volume colors used
          in the project. Colors are represented in RGB in hexadecimal
          format. Example: `#000000' would be black, and `#FFFFFF'
          would be white.

        - all_surfaces_colors: returns a list of the surface colors
          used in the project. Colors are represented in RGB in
          hexadecimal format. Example: `#000000' would be black, and
          `#FFFFFF' would be white.

        - all_cuts_colors :returns a list of the cut colors used in the
          project. Colors are represented in RGB in hexadecimal format.
          Example: `#000000' would be black, and `#FFFFFF' would be
          white.

        - cur_volumes: returns a list of the visible volumes.

        - cur_surfaces: returns a list of the visible surfaces.

        - cur_cuts: returns a list of the visible cuts.

        - all_display_styles: returns a list of all types of display
          styles avalaible.

        - cur_display_style: returns the current display style.

        - all_display_renders: returns a list of all types of render
          avalaible.

        - cur_display_render: returns the current rendering  method.

        - all_display_culling: returns a list of all types of culling
          avalaible.

        - cur_display_culling: returns the current culling
          visualization.

        - cur_display_transparence: returns `Opaque' or `Transparent'
          depending on the current transparency. Transparency is chosen
          by the user in the Select & Display Style window.

        - cur_display_body_type: returns `Massive' if the option
          Massive of the window Select & Display Style is selected. It
          returns `Hollow' if that option is not activated.

        - all_analisis: returns a list of all analisis in the project.

        - all_steps "analisis_name": returns the number of steps of
          "analisis_name".

        - cur_analisis: returns the name of the current analisis.

        - cur_step: returns the current step.

        - all_results_views: returns all avalaible result views.

        - cur_results_view: retuns the current result view.

        - cur_results_list: this option has one more argument: the kind
          of result visualization must be given. The avalaible kinds of
          result visualization are given by the option
          all_results_views. The comand returns a list of all the
          results that can be represented with that visualization in
          the current step of the current analysis.

        - results_list: this option has three arguments: the first
          argument is the kind of result visualization. The avalaible
          kinds of result visualization are given by the option
          all_results_views. The second argument the analysis name. The
          third argument is the number of step. The comand returns a
          list of all the results that can be represented with that
          visualization in the given step.

        - cur_result: returns the current selected result. The kind of
          result is selected by the user in the View results window.

        - cur_components_list "result_name": returns a list of all the
          components of the result "result_name".

        - cur_component: returns the current component of the current
          result.

        - main_geom_state: returns if the main geometry is `Deformed'
          or `Original'

        - main_geom_all_deform: returns a list of all the deformation
          variables (vectors) of the main geometry.

        - main_geom_cur_deform: returns the current deformation
          variable (vectors) of the main geometry.

        - main_geom_cur_step: returns the main geometry current step.

        - main_geom_cur_anal: returns the main geometry current
          analysis.

        - main_geom_cur_factor: returns the main geometry current
          deformation factor.

        - show_geom_state: returns if the reference geometry is
          `Deformed' or `Original'.

        - show_geom_cur_deform: returns the current deformation
          variable (vectors) of the reference geometry.

        - show_geom_cur_analisis: returns the reference geometry
          current analysis.

        - show_geom_cur_step: returns the reference geometry current
          step.

        - iso_all_display_styles: returns a list of all avalaible
          display styles for iso surfaces.

        - iso_cur_display_style: returns the current display style for
          iso surfaces.

        - iso_all_display_renders: returns a list of all types of
          render avalaible for iso surfaces.

        - iso_cur_display_render: returns the current rendering  method
          for iso surfaces.

        - iso_cur_display_transparence: returns Opaque or Transparent
          depending on the current transparency of iso surfaces.

        - contour_limits: returns the minimum and maximum value of the
          contour limits. Before each value, the word `STD' appears if
          the contour limit value is the default value, and `USER', if
          it's defined by the user.

        - animationformat: returns the default animation format.

        - cur_show_conditions: returns the option selected in the
          Conditions combo box of the Select & Display Style window.
          (Possible values: `Geometry Mesh None')

        - all_show_conditions: returns all the options avalaible in the
          Conditions combo box of the Select & Display Style window.
          (`Geometry Mesh None')

        - cur_contour_limits: returns the minimum and maximum value of
          the current value.

        - current_color_scale: returns a list of the colors used for
          the color scale; the first element of the list is the number
          of colors. Each color is represented in RGB in hexadecimal
          format. Example: `#000000' would be black, and `#FFFFFF'
          would be white.

   * .central.s info AutomaticTolerance
     This command returns the value of the Import Tolerance used in the
     project. This value is defined in the Preferences window under
     Import.

   * .central.s info RGBDefaultBackground
     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.

   * .central.s info list_entities status
     This command returns a list with general information about the
     current GiD project.
          Example:
          in:  `.central.s list_entities status'
          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%'

   * .central.s info list_entities
     This command returns information about entities.
     It has the following arguments:
        - Points/Lines/Surfaces/Volumes/Nodes/Elements: type of entity.

        - entity_id: number of entity. It is also possible to enter a
          list of entities (example: `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').

     With option -more returns more information about the entity.
     Option -more used with lines, returns the length of the line, its
     radius (arcs), and the list of surfaces which are higuer entities
     of that line; used with elements, it returns the type of element,
     its number of nodes and its volume.

          Example 1:
          in:  `.central.s 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:  `.central.s 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:  `.central.s 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'

   * .central.s info ListMassProperties
     This command returns properties of the selected entities. It
     returns the length if entities are lines, area, if surfaces,
     volume if volumes, or the gravity center if entities are nodes or
     elements.
     It has the following arguments:
        - Points/Lines/Surfaces/Volumes/Nodes/Elements: type of entity.
          entity_id: number of entity. It is also possible to enter a
          list of entities (example: `2 3 6 45') a range of entities
          (example: entities from 3 to 45, would be `3:45').

          Example:
          in:  `.central.s info ListMassProperties Lines 13 15'
          out:
          `LINES
          n. Length
          13 9.876855
          15 9.913899
          Selected 2 figures
          ________________________
          Total Length=19.790754'

   * .central.s info problemtypepath
     This command returns the absolute path to the current Problem Type.

   * .central.s info GiDVersion
     This command returns the GiD version number. For example 6.2.0b.



File: gid.info,  Node: Managing menus,  Next: HTML support,  Prev: Control functions,  Up: TCL-TK extension

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
(*note 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:
   * CreateMenu {new_menu_name prepost}
     Creates a new menu. New menus are inserted between the Calculate
     and Help menu.
        - `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
          or `"PREPOST"' to create the menu in the pre and postprocess

   * InsertMenuOption {menu_name option_name position command prepost
     [insert/replace] }
     Creates a new option for a given menu in a given position
     (positions start at 0). By default, if it already exists an option
     in the given position, that option is substitued by the new one.
     If the `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 ">".
          Example: `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
          or `"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.

   * RemoveMenuOption {menu_name option_name prepost}
     Removes an option of a given menu.
        - `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
          or `"PREPOST"' to remove an option of the pre and the
          postprocess menus

     NOTE: `menu_name' and `option_name' are case sensitive.
   * UpdateMenus {}
     Updates changes made on menus. This function must be called when
     all calls to `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


File: gid.info,  Node: HTML support,  Next: GiD version,  Prev: Managing menus,  Up: TCL-TK extension

HTML support
============

   GiD offers a function which opens an internal HTML browser; that may
be useful if you want to add online help to your problem type.

     1 - Create a directory named `html' inside your problem type
     directory
     2 - Call HelpWindow "CUSTOM_HELP" "problem_type_name", where
     `problem_type_name' is the name of your problem type with the
     `.gid' extension (for example, `cmas2d.gid').
     3 - Function HelpWindow opens the file "index.html" which must be
     inside the `html' folder.

   It's a good idea to call the function HelpWindow "CUSTOM_HELP"
"problem_type_name" using the menu functions (*note 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


File: gid.info,  Node: GiD version,  Next: Using EXEC in GiD,  Prev: HTML support,  Up: TCL-TK extension

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.


File: gid.info,  Node: Using EXEC in GiD,  Next: Detailed example - TCL-TK extension creation,  Prev: GiD version,  Up: TCL-TK extension

Using EXEC in GiD
=================

   The TCL language has the `exec' command used to invoke a subprocess.
This command treats its arguments as the specification of one or more
subprocesses to execute. It's possible to invoke a subprocess from GiD
using this option.

   Example: invoking a process in the background
     exec netscape http://gid.cimne.upc.es &

Note: In Windows, instead of `&' it's necessary to put `>& NUL: &' to
run the process in the background. Example: `exec PROGRAM_NAME >& NUL:
& '

File: gid.info,  Node: Detailed example - TCL-TK extension creation,  Prev: Using EXEC in GiD,  Up: TCL-TK extension

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.

   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}

          proc InitGIDProject {dir } {
          
            set materials  [.central.s info materials]
            set conditions [.central.s 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}
          proc CreateWindow {dir mat cond} {
          
           set w .gid.win_example
          
           InitWindow $w "CMAS2D.TCL - Example tcl file" ExampleCMAS "" \
          	    "" 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 " Avalaible materials: $mat"
           label $w.information.conditions  \
                  -text " Avalaible 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}

          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]
          	   }
          
          
            .central.s process escape escape escape escape
          
            .central.s 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
          
          
          
            .central.s process escape escape escape escape
            .central.s process geometry create NurbsSurface Automatic \
            4 \
            escape \
          
            .central.s process zoom frame escape escape escape escape
           }

     A 2D surface (a 4 side 2D polygon) is created. The points of this
     surface are chosen at random.

