Which scripting part or Pyansys modules can I use to obtain results in the .avz format?
As we have ansys viewer to read .avz files to get visualisation in 3D.
Is their anything in pyansys same as ansys viewer or do we have any other extensions...?
Best Answers
-
Hi @Abel Ramos
But in PyDPF, 3D interactively outputs are unable to extract. If you have an overview on this.? Please share hereRegards
Naveen.0 -
One option is to use PyWorkbench and PyMechanical to read the .rst file in Mechanical and then produce the .avz similar to this blog post:
https://developer.ansys.com/blog/create-report-saved-mechanical-session-mechdb-or-mechdatHere is a blog post that describes how to do the first part manually:
https://simutechgroup.com/post-processing-apdl-models-inside-ansys-workbench/@AKD-Scripting-Team , Do we have any exiting scripts to create a Mechanical project from an .rst as described above?
0
Answers
-
Hello, depending on your needs you can use pyDPF (or dpf in mechanical) to plot your results natively in a 3D visualization.
For example:
https://post.docs.pyansys.com/Best Regards,
0 -
## AVZ export import wbjn import os userdirectory = wbjn.ExecuteCommand(ExtAPI,'returnValue(GetUserFilesDirectory())') results =ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.Result) #loop over the results for result in results: result.Activate() mvm = ExtAPI.Graphics.ModelViewManager #avzFilename = r'D:\Temp\{}.avz'.format(result.Name) avzFilename = os.path.join(userdirectory,'{}.avz'.format(result.Name)) mvm.Capture3DImage(avzFilename)
1 -
import wbjn import os def ExportAVZ(obj,export_directory): obj.Activate() # export_directory = wbjn.ExecuteCommand(ExtAPI,'returnValue(GetUserFilesDirectory())') filename = os.path.join(export_directory,'{}.avz'.format(obj.Name)) ExtAPI.Graphics.Export3D(filename) return filename
This was taken from this blog post, which you might find useful.
1 -
Hi @Landon Mitchell Kanner , Thanks for response.
But, How can we do with PyAnsys using .rst files, instead of doing with IPython (Mechanical scripting).?
Naveen.
0 -
Attached is an in-work ACT extension that will work in Mechanical Stand Alone mode (not workbench). You can open Mechanical and load the app. There is a single button that will let you open a results file.
Upon selection it will launch MAPDL in batch in background, create a .cdb file from the .rst file, import that .cdb file into mechanical, create an analysis, and read in that results file for post processing
This is a work-in progress, in the sense it has limited testing, but the code is all open for review/modification to your own needs. It also does not imply this will be a native feature/function in the future, just a demonstration that such a workflow can be executed from the Mechanical API.
0 -
Here is code to leverage @Mike.Thompson 's solution to create an .avz from an .rst using pyMechanical:
RstPath = r'D:\Temp\project_Mech_Files\StaticStructural\file.rst' library = r'C:\Users\lmkanner\Downloads\ResultsFileMechReader\ResultsFileMechReader' from ansys.mechanical.core import App import sys import os from ansys.mechanical.core import global_variables outfolder = os.path.split(RstPath)[0] app = App() globals().update(global_variables(app)) sys.path.append(library) sys.path.append(r'C:\Program Files\ANSYS Inc\v{}\aisol\DesignSpace\DSPages\Python'.format(app.version)) import RunAPDL RunAPDL.Initialize(ExtAPI, Ansys) SI, CdbPath = RunAPDL.GetCdbFileFromResultFile(RstPath) import RunMech RunMech.Initialize(ExtAPI, Ansys) RunMech.ImportResultsToCurrentSession(CdbPath, RstPath, library) def ExportAVZ(obj,export_directory): obj.Activate() # export_directory = wbjn.ExecuteCommand(ExtAPI,'returnValue(GetUserFilesDirectory())') filename = os.path.join(export_directory,'{}.avz'.format(obj.Name)) ExtAPI.Graphics.Export3D(filename) return filename results =ExtAPI.DataModel.GetObjectsByType(Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Result) for result in results: avz = ExportAVZ(result,outfolder)
0 -
@Landon Mitchell Kanner @AKD-Scripting-Team & @Mike.Thompson
Thank you for the support and guidance.0