How to use APDL Command Snippets in your ANSYS Mechanical Model

Categories:

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

Join PADT and the global Ansys user community for this year’s online conference.

Multiple Tracks | Every Physics & Every Industry

Hear from Ansys Leadership | Presentations from Customers on How They Use Ansys

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

Technical Expertise to Enable your Additive Manufacturing Success.

Share this post:

Upcoming Events

May 29
, 2025
Applying Digital Engineering across Space Mission Analysis and Design: Payload - Webinar
Jun 03
, 2025
Experience Stratasys Truck Tour - Denver Colorado
Jun 03
, 2025
Accelerate Electronics Thermal Workflows with Ansys Discovery and Ansys Icepak - Webinar
Jun 03
, 2025
Smart Manufacturing and Operations Enabled by Simulation - Webinar
Jun 04
, 2025
Composites & Structural Optimization Updates in Ansys 2025 R1 - Webinar
Jun 05
, 2025
Using Digital Engineering for a Structural, Thermal, and Optical Performance Workflow - Webinar
Jun 09
- Jun 11
, 2025
TechConnect World 2025
Jun 12
, 2025
Design and Test: Critical Links for Mission Success - Webinar
Jun 17
, 2025
Ansys Virtual Workshop - Fatigue & Durability Workflows with Ansys Mechanical & nCode
Jun 18
, 2025
Fluent CPU - UI & UX Updates in Ansys 2025 R1 - Webinar
Jun 16
- Jun 20
, 2025
Turbo Expo
Jun 24
, 2025
Cardiovascular Digital Twins: From Bench to Bedside - Webinar
Jun 25
, 2025
E-Mobility and Clean Energy Summit
Jul 02
, 2025
Electric Machine & Consumer Electronics Updates in Ansys 2025 R1 - Webinar
Jul 11
, 2025
2025 Aerospace, Aviation, Defense and Manufacturing Conference
Jul 16
, 2025
HFSS Updates in Ansys 2025 R1 - Webinar
Jul 16
- Jul 17
, 2025
Ansys Simulation World 2025
Aug 10
- Aug 13
, 2025
SmallSat 2025

Search the 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: