Running an APDL Command Snippet for Every Load Step in ANSYS Mechanical

This week went by very fast, and I never got time to do the more advanced article on tables to follow up on last week’s article.  So I was going to give up till someone stopped by my office to ask a question and I thought my simple and clever answer would make a nice quick, but useful, posting.

What he need to do was apply fairly complicated loading over multiple substeps. Do some *get’s, calculate some stuff, then apply a load. I immediately thought of a trick we used in the early days of ANSYS Mechanical (before it was called ANSYS Mechanical) where we would put in a script that redefined the solve command as nall (*abbr,solve,nall).  You then used your own code to do the solves.

This made us feel very smart and clever.

However, something in the corner of my brain was saying “dumb and silly.” So I fired up 14.0 and realized that my brain was right, you don’t have to trick ANSYS Mechanical any more. The developers now allow you  to specify load steps and such for preprocessing command objects.  I should know this because I did a seminar on APDL Command Objects. .

Darn no article for this week, it was already covered. 

But just to make sure I looked through the PowerPoint and found that the ability wasn’t covered. Yipee! I have an article, now to stretch it out make it look important!

If you insert a command object into your model setup:


You end up with a Details view like so:


Under definition you can set “Step Selection Mode”  This simply lets you determine if the APDL code in the command object is applied every load step (All), at the first (First), at the last (Last), or if the command object is only applied to a specific load step number (By Number). 

  If your complicated loading/modification to your model is the same commands for every load step, pick All and enter your commands. If it varies by load step in some way, you have two choices. You can write a set of commands for each load step, or you can write a macro that uses a *get,nmstp,active,,solu,ncmls and then use logic to figure out what you need to do.

So, pretty simple, but it opens up a lot of possibilities when you need to do some simple tweaks during a multi-step solve.

There, now I don’t feel like a looser for not doing an article this week.

2 Replies to “Running an APDL Command Snippet for Every Load Step in ANSYS Mechanical”