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. James |
Query Variable from Script
James,
That is fairly straight forward to extract out of EnSight. The main python function you want to use is : ensight.query(ensight.QUERY_PROBE_DATA) 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.variables.activate(varname) ensight.query_interact.select_varname_begin(varnam e) ensight.query_interact.query("xyz") ensight.part.select_begin(partid) ensight.query_interact.create(xloc,yloc,zloc) # 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 (kevin@ceisoftware.com) |
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, James |
James,
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. -Kevin |
Hi Kevin,
Thanks for the info I wasn't aware of this document but I am now! James |
You can also find many examples on
http://pythonexchange.com/ In these tools you find many hints how to script ensight Greets Jim |
Hi kevin,
in query show info i could get required scalar value for particular node/ Element. how to get the same by Script. i want to use that scalar value x=getinfo('element 123') or x=get scalar value(node 1) |
All times are GMT -4. The time now is 04:59. |