How to use APDL Command Snippets in your ANSYS Mechanical Model


One of the most powerful features in ANSYS Mechanical is the fact that it leverages the ANSYS Mechanical APDL solver. This modern and ever-improving interface allows users to create, run, and post-process models with power and ease. But it also allows users to access the power of the underlying solver through the native language it uses, APDL. You can have your cake and eat it too.

A lot has changed since we did our last seminar on this topic, back in May of 2011. ANSYS Mechanical has grown and scores of features have been added, removing the need for a lot of the functions and features that people needed APDL scripts for. But again and again our tech support people find that users push the envelope with their tools and to do what they need to do, they need to get inside the solver tool using the APDL scripting language.

That is why we decided to update that seminar as a blog article, making it more searchable while we bring it up to date. There is a lot to cover, so get comfortable.

Background and Foundations

If you have never used ANSYS Mechanical APDL a lot of what we are going to talk about may sound like another language. That is because it is. The key thing to remember is that when you click Solve in ANSYS Mechanical, it generates an input file that is then read into ANSYS Mechanical APDL in batch mode.

This is the original ANSYS product that Johns Swanson wrote in the early 70’s. It was released in 1971. (if you want to learn more about the history of ANSYS, please check out our interview with Dr. Swanson.) Over the following decades, the program grew to become a fully featured FEA program that could do almost anything. However, the user interface, and especially the embedded geometry tool, could not keep up and much of the pre- and post-processing was replaced by ANSYS Mechanical. But all of those capabilities are still there and accessible to the user.

Before we go further, let’s talk about the simple model we will be using for this post. It is what we call a “Towers of Test” model. Two beams held at their base that are loaded in various ways. Small, fast, and a great way to experiment with new fet

What is APDL and why do we need it?

APDL stands for ANSYS Parametric Design Language. One of the key breakthroughs that ANSYS introduced in the late 80’s was converting their input file from a formatted text file that simply specified the model being solved with a simple text command language that could also define the model fully. In addition, it allowed:

  • Every user-supplied value in the file, numbers or text, to become a parameter. The parameters can be numbers, strings, or multi-dimensional arrays of numbers or strings.
  • Flow control of the text file by introducing if-then-else statements and do-loops.
  • Functions to interrogate the database at any point during the model creation, solve, or post-processing. The values returned by the function could be stored as parameters.
  • Operators to modify the parameters. This includes math operators, common numerical functions, and string tools.

If you have only used fully interactive engineering software, then the power of these capabilities may not be apparent. But as you add small snippets to ANSYS mechanical, the openness full capability of the ANSYS Mechanical APDL solver will become apparent.

To see the APDL that ANSYS Mechanical write out, just look in the ds.dat file. That is the “Input File” that the program generates and sends to the solver.

You can find it with the “File” viewer on the project page.

ANSYS Mechanical file tool project page

Or you can write out the file wherever you want from within ANSYS Mechanical by selecting what you want to solve, and click the Environment > Tools > Write Input File command. >>>>>>> NOT WORKING

ANSYS Mechanical write input file

What is a Snippet/Command Object?

How do you add Snippets to your ANSYS Mechanical Model?

What else do you need to know before you dive in?

Item Snippets

Pre-Processing Snippets

Post Processing Snippets

Suggestions, Resources, and Final Thoughts


Get Your Ansys Products & Support from the Engineers who Contribute to this Blog.

Technical Expertise to Enable your Additive Manufacturing Success.

PADT’s Pulse Newsletter

Keep up to date on what is going on at PADT by subscribing to our newsletter.

By submitting this form, you are consenting to receive marketing emails from: . You can revoke your consent to receive emails at any time by using the SafeUnsubscribe® link, found at the bottom of every email. Emails are serviced by Constant Contact

Share this post:

Upcoming Events


Experience Stratasys Truck Tour: Houston, TX


Structures Updates in Ansys 2024 R1 (2)


Experience Stratasys Truck Tour: Houston, TX


Experience Stratasys Truck Tour: Albuquerque, NM


Fluent Materials Processing Updates in Ansys 2024 R1 - Webinar


Experience Stratasys Truck Tour: Los Alamos, NM


Simulation World 2024


Simulation World 2024


Simulation World 2024


Optics Updates in Ansys 2024 R1 - Webinar


Connect Updates in Ansys 2024 R1 - Webinar


Structures Updates in Ansys 2024 R1 (3) - Webinar


E-Mobility and Clean Energy Summit


Fluids Updates in Ansys 2024 R1 - Webinar


2024 CEO Leadership Retreat


PADT30 | Nerdtoberfest 2024

Search in PADT site

Contact Us

Most of our customers receive their support over the phone or via email. Customers who are close by can also set up a face-to-face appointment with one of our engineers.

For most locations, simply contact us: