Ansys workbench scripting
Hello Everyone,
I am trying to extract results from CFD-Post in workbench environment through script. I have created the workbench script (Ex: saving the velocity contour as a image file). Now i wanted to run it in loop so that i can extract results from multiple results file. With the script i am able to open different workbench files but i am unable to save the velocity contour i.e i am unable to change Hardcopy Filename in the loop. please help me to solve this problem (i already created dp1,dp2,dp3 and dp4 folders in respective path) # encoding: utf-8 import os for i in 1,4: #os.mkdir('dp%s' %i) Open(FilePath="F:/Workbench_40_dp%s.wbpj" %i) #worked SetScriptVersion(Version="15.0") system1 = GetSystem(Name="CFX 11") results1 = system1.GetContainer(ComponentName="Results") results1.Edit() results1.SendCommand(Command="""HARDCOPY: Antialiasing = On Hardcopy Filename = "F:/results/temp/dp"str{i}"/velocity.png" #not working Hardcopy Format = png Hardcopy Tolerance = 0.0001 Image Height = 600 Image Scale = 100 Image Width = 600 JPEG Image Quality = 80 Screen Capture = Off Use Screen Size = On White Background = Off END >print""") results1.Exit() |
Did it run when providing a name NOT created by a variable?
I would guess that you have to use PERL syntax in order to make this insertion.
|
Quote:
i know it is two years ago, but at the moment i have the same problem to change the the file names. Did you find a solution ? |
Try this
Hi,
if you looking for a solution, have a look here: https://www.researchgate.net/publica...t_and_ParaVIEW If you have further questions, you are welcome. Have fun. |
Hey FluidWarrior,
thank you for your answer. But unfortunatelly it did not help a lot. My problem is that i can´t change the name of the exported file during my constructed loop. The loop is working but it always saves the exported files with the same name. But i need to rename the files in every loop. At the moment i still use the Journal script of workbench. If you have an idea how i can write my own script to get the files exported it will help me a lot. Thank you for your help |
1 Attachment(s)
Thank you for your help so far. In order to find the solution faster, I want to be more specific:
I wrote a Journal to run a sequence of simulations. A part of the journal is to vary the temperature and velocity boundary conditions according to the results of the simulation in the iteration before. I want to save the results of the heat transfer and wall shear stress at a specific boundary for each computed file (see the picture attached). Unfortunately, I don’t know how to change the file name every iteration such that the old data is not overwritten. This is due to the syntax of the commands that starts in line 35. Do you know how to interrupt the syntax and to include the values for T1, v1 and v2? Export File = E:/BA/Test/Simulation_files/user_files/Results_T1=443,15_v1=6_v2=0,5.csv Best regards :) |
Solution
1 Attachment(s)
Hey everyone,
i have a solution for my own described problem. The important idea of my the problem is that the command “””EXPORT:…””” is a string. So you can define several substrings and combine them to generate a new name. Attached you find the improved version of my code. First, I defined a string called fname_P1 which is the first part of the command to send. Then, I defined a string called fname_P3 which is the third part of the command to send. At the beginning of my for-loop i also defined a string with the expression of my variable which i will change. [V1 = str(variable), you can´t see it in the picture below] Finally I used the command to export the results: results1.SendCommand(Command=fname_P1 + V1 + fname_P3) The name of the csv file is E:/BA/Test/Simulation_files/user-files/Results_V1.csv I hope I can help you, if you have the same problem I had :) Best regards. |
Thanks Fabisch. Very helpful.
|
All times are GMT -4. The time now is 08:36. |