Closed amscosta closed 1 month ago
There are newer versions of that script which are more compliant and robust with more recent versions of EnSight and python usage. Please reach out directly to kevin.colburn@ansys.com for direct assistance.
Hi @amscosta , I would like also to point out that converting EnSight scripts into PyEnSight scripts, while it is usually simple, has some implications because of the different nature between the "ensight" module in EnSight, and the session "ensight" class instance.
The do share the same API, though they are completely different objects
Things like "from ensight.objs import " cannot work since in PyEnSight "ensight" is not a module, but a class instance. Also in PyEnSight the "EnSight Extensions" are not exposed, being, indeed, EnSight extensions and not PyEnSight extension (hence "from ensight.core.tool_extension import " cannot work in PyEnSight).
Finally, the "cei" module is not exposed in PyEnSight, and the same applies for any Qt application available in the EnSight Python. These are all features that, given their nature, are only available in EnSight.
For guidance on converting EnSight scripts into PyEnSight scripts, please refer to https://ensight.docs.pyansys.com/version/stable/user_guide/api_differences.html and https://ensight.docs.pyansys.com/version/stable/user_guide/cmdlang_native.html
Hi All, I found this python script for converting xyz_value in ensight format. Unfortunatelly is not working inside ensight 2023R1, following the macro procedure. Can some knowledgeable expert know the trick for making it run ? (Maybe calling pyensight csv2point_n.txt inside a jupyter notebook) Thanks .
ENSIGHT_USER_DEFINED_BEGIN
FACTORY=ctor
ENSIGHT_USER_DEFINED_END
#
Python Script to convert from a comma separated 5 column file (X,Y,Z,Var1,Var2) to
EnSight Case format
Assume temperature as Var1
and strain_rate as Var2
Kevin Colburn
CEI
June, 2010
#
# import math,ensight from cei.qtgenericdlg import from ensight.objs import from ensight.core.tool_extension import * #
This routine converts a float value to a % 12.5e string with two places for the exponent.
Microsoft has decided to defy the C Standards and write out three values in the
exponent [-]m.ddddde+xxx rather than only two per the C STANDARD [-]m.ddddde+xx
# def float_to_exponent_string(float_val):
converts a float to a 12-character string with three-character exponent (windows)
# if out_str[1] == '-' or (out_str[0]==' ' and out_str[1]==' '): out_str = out_str[1:]
# def runkevincode(): #
create a user interface where the user selects the file for conversion
#
Extension class
# class convert_csv(tool_extension): def init(self): tool_extension.init(self,"convert_csv",file,1.0) self.setText("Convert Excel CSV to EnSight Format") self.setDesc("Convert Excel CSV to EnSight Format") self.setTooltip("Select Excel CSV and Convert to EnSight Case Format") dir = os.path.dirname(file) self.setIcon(os.path.join(dir,"csv2en.png"))
self.cmdClear()
#
Execute the tool from the gui
# def run(self): runkevincode() #
Construct the extension instance
# def ctor(parent): list = [] obj = convert_csv() if (parent): parent.addChild(obj) list.append(obj) return list