Skip to content

Free Training: Scripting for Ansys Mechanical

Recently LEAP delivered online training on scripting for Ansys Mechanical which was very well received by our customers. We decided to make the two training sessions available to the wider Ansys community, so if you would like to learn how Ansys Mechanical scripting can help to improve your efficiency, please read on and watch the recordings below.

This first session of our two-day training course provided a holistic view of Python to get users familiarised with the underlying structure of Ansys Scripting. In this training, Leap’s Application Engineer Tiffiny Vann gives an overview of Python and IronPython, an open-source implementation of Python based on the .Net framework. The training covers various topics, from basic coding structure to math operations in the Ansys Scripting Module. Further, the session dives deeper into the coding, exploring variables and functions in Python script showcasing various examples. Lastly, it touches on the common data types used in day-to-day Ansys coding, including List Data type through range command, If statement, While Loop and For Loop.

Watch the recording of say one of the training in the clip below. Please note that you can browse and skip between sections of the training by hovering over the video timeline.

In recent years, Ansys has made significant enhancements to its automation capabilities for Workbench and Mechanical. This has enabled users to save an ample amount of time by employing such automation tools. In the second session of our two -day online training, Khesh Selvaganapathi, Application Engineer at LEAP Australia discussed the Scripting Module in Ansys Mechanical, outlining its setup, capabilities and associated performance gains.

In the video below from day two of our training, Khesh provides an overview of Mechanical Scripting and its underlying language IronPython. Again you can skip between the different sections of the video by navigating with the timeline – a brief overview of each of these key sections is also provided below.

Jump to each section in the video above to learn more about:

Introduction to Scripting in Mechanical

This section explains the Mechanical scripting GUI – the location of buttons to start, stop & debug the script and the Built-In Code snippets available in Ansys Mechanical, which allow you to perform basic processes with just a few clicks.

Mechanical API

Explains the Application Programming Interface, better known as API, and how to download the API from the Ansys store. This section also demonstrates the workflow of API and how API is made up of several components, including Class, Methods and Properties.

Example showing automation of various tasks in Mechanical using a Trailer model

This section explains the differences in coding style between the recorded script generated by Ansys Mechanical and the manually coded script. In addition, the video showcases an example demonstrating the approach to add a point mass, mesh, contact, boundary condition and solution information to a model.

Key concepts in Python Scripting

This section covers key concepts that can be used to improve the coding workflow. This includes commonly used shortcuts in the Shell & Editor GUI, Autocomplete text editor, Zip command to allow parallel iterations and the Transaction command to name a few.

Example showing automation of beam probes from beam connections and exporting to CSV file

Using a test case, this section showcases the benefits of scripting in Ansys Mechanical. In this model, Beam probes containing solution information such as Axial Force, Shear Force, Torque, etc., were exported to a CSV file in no time, which would otherwise have to be done manually by the user.

Exporting Graphics

Another interactive feature that we can access using scripting is exporting images and video files. The benefit of using scripting is that it provides more control over the export properties such as resolution, legend, camera angle and more.

Further automation tools & Final remarks

The final section covers enhanced scripting features in other areas of Ansys such as within Workbench, which allows users to control and automate the tedious processes in Engineering Data and DesignXplorer. Scripting has also allowed users to automate parameters inside the Workbench. Another helpful feature that Ansys supports is powering specialised workflows using Data Processing Framework DPF. One of the examples of DPF automation is exporting high-stress geometries to an STL file. In addition to this, Ansys also offers an add-on module called Ansys Customisation Tool (ACT) that automates repetitive tasks, manipulates input files and integrates with external processes and codes.

We hope that you found this training helpful. We welcome Ansys customers in Australia and New Zealand to contact the LEAP technical support team if you require any further information or assistance with scripting in Ansys Mechanical.

2 thoughts on “Free Training: Scripting for Ansys Mechanical”

  1. Syed Imad ul Haq Haqqi

    Hi,
    Is it possible to upload the Ansys wbpz files at the youtube links please to practice with the video. Gives more confidence in use.
    Regards,

  2. Do you have a better quality version of the Intro to Python video? The resolution is quite low and I cannot see the screen. Video 2 is better.

Leave a Reply

Your email address will not be published. Required fields are marked *