Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note: -np- mean ‘No-Process’ (that the words are not GiD process keywords) and instead the next command is expected to be Tcl code. It is used as a fast way to run a simple procedure or re-define code.

Use copy/paste code after -np-

In particular there are some predefined Tcl procs that run python code, like GiD_Python_Exec that expects the python code to be evaluated

...

There are other procs similar to GiD_Python_Exec ,like GiD_Python_Eval (for a single instruction and value is returned) or GiD_Python_Call (to invoke a function that must be previously defined)

Source a file with the code

The normal way to write long Python code is write it in a .py file.

...

GiD_Python_Source is a Tcl proc that expects the name of a python file with the code to be sourced

Example: matplotlib graph of two curves

The file <GiD>/scripts/tohil/doc/demo_matplotlib.py contain a code like the one of the image

...

then this window will appear:

...

Python force reload a file

Other Tcl procs related to source Python code are GiD_Python_Import_File and GiD_Python_Import

...