CFD Online Discussion Forums

CFD Online Discussion Forums (
-   EnSight (
-   -   Variable from point query (scripting) (

jamesm January 18, 2013 08:08

Variable from point query (scripting)
Hi- wondering if anyone can help me with a simple problem but couldn't find anything from a search. I'm using Ensight 9.2

I'm looking to save the result of a query on a cursor position as a variable in a python script. So what I'd like is to set:
pref = Value of pressure on part 1 at position (x,y,z)

Many thanks in advance.


kevincolburn January 19, 2013 11:05

Query Variable from Script

That is fairly straight forward to extract out of EnSight. The main python function you want to use is :

I've provided below a few other items in terms of setup and use of the xyz query. You may or may not need this additional information, but should provide further context for your inquiry. So, the following example I set the xyz location with the "xloc, yloc, zloc" variables, the variable name and part to query from. The next block is the creation of the query, while the final block is the extraction of the query variable, and do with it what I want.

# Setup first the xyz location, the variable of interest, the parent part.
xloc = 0.94095
yloc = 0.22981
zloc = 0.03521
varname = "Energy"
partid = 1

# Standard EnSight commands to create a probe at this XYZ location
ensight.query_interact.select_varname_begin(varnam e)

# Ask EnSight for the value at that probe location
a = ensight.query(ensight.QUERY_PROBE_DATA)

# Print the whole information
print a

# alternative, print out the first variable
vname = a[0][0][0]
pref = a[1][0][0]
print "Value of ", vname," is ",pref

Let me know if that addresses your question or not... or it inspires more.

-Kevin Colburn

jamesm January 22, 2013 14:15

Hi Kevin

Thanks for your information works exactly as I wanted.

Is there documentation / resource of functions such as these on-line anywhere?

Thanks again,


kevincolburn January 22, 2013 18:12


The "Interface Manual", chapter 6 has the majority of what you are looking for in terms of Python-EnSight. In the User Defined Tools area for EnSight 10, there are some links to our Google Docs which has a bit more low-level Python operation which may help.


jamesm January 24, 2013 04:15

Hi Kevin,

Thanks for the info I wasn't aware of this document but I am now!


JimKnopf March 28, 2013 03:18

You can also find many examples on

In these tools you find many hints how to script ensight


All times are GMT -4. The time now is 02:11.