Using the Mechanical scripting window
Open Ansys Mechanical and access View → Scripting, then enter:Step-by-Step explanation
1. Import required modules
mech_dpf helper module and the main DPF namespace. Both are available in Mechanical’s IronPython environment.
2. Set ExtAPI context (CRITICAL!)
3. Access Mechanical analysis
4. Get result file path
4. Create DPF data source
5. Create DPF model
Using DPF operators
DPF uses an operator-based approach for data processing. Here’s an example extracting stress:Using in a Python Result object
You can also use DPF in a Python Result object for visualization:- Must use
define_dpf_workflow(analysis)function - Create
dpf.Workflow()for visualization - Use
SetOutputContour()to specify what to plot - Call
Record()and setthis.WorkflowId
Generating DPF documentation
To generate comprehensive DPF documentation in Mechanical:What’s next?
Now that you’ve run your first script in Mechanical, explore:- User Guide - Learn DPF core concepts
- Examples - See more Mechanical-specific examples
- API Reference - Detailed API documentation