Tempe, AZ 85284
2
Just like the APDL language it was designed to edit, the PeDAL
editor is very simple and
straightforward, but if you dig deeper into it you will find many
ways to be more efficient. In this
tutorial we will mostly cover the basics of how to create APDL
macros in PeDAL, and use the
integrated help. At the end we will look at some of the more
advanced features. We will be
using examples from PADT's "Introduction to the ANSYS Parametric
Design Language " book.
Getting Started To begin we will be typing in bracket1.mac from
"Introduction to the ANSYS Parametric Design
Language" We will type in the whole thing to get some practice with
the interface.
1. From the Windows Start m menu select PADT, Inc>PeDAL X64. You
should see:
2. Note the text editor in the left window and the browser, with
the online PeDAL help on
the right.
3. To get warmed up we are going to slowly type the first command,
finish, and see what
the interface does. Click in the text editor window and type in the
first letter of the first
line for the macro: f
F is a command (force) so it shows you the syntax for that command
and the one line
3
4. Now type the i. The interface searches for valid APDL commands
and shows you a list
with the first "fi" command highlighted.
5. Type in the n and it will highlight "finish" You can press the
TAB key and PeDAL will
insert "finish" You can also type in a comma (,) and it will also
use the currently selected
keyword.
6. Press Enter to go to the next line and notice two things:
Finish is highlighted in a burnt orange color. This is because the
default color for a
"processor" command is set to that color.
7. Enter in the next two lines: /clear then /prep7.
Note that it still shows you choices as you type and when you enter
the full command, it
shows the syntax and short description.
/clear is blue, the color of a standard command, and /prep7 is
burnt orange because it
changes the processor.
8. Next we are going to type in a bunch of keypoint coordinates.
But since this is the first
time we are doing more than just the keyword, just do the first one
by itself: k,1,0,0,0
9. As you type in the first line (k,1,0,0,0) note that the syntax
clue shows you what
argument you are currently entering.
5
This is one of the most useful features in PeDAL because it is
almost impossible to remember all
the arguments to a command, but with the prompting you get enough
information to enter the
command correctly without having to consult the manual.
10. Enter in the rest of the keypoints:
k,2,0.25,0,0
k,3,0.25,4-.25,0
k,4,3,4-.25,0
k,5,3,4,0
k,6,0,4,0
11. Note that the keyword is highlighted blue and the numbers are
in beige.
12. What if you type in a keyword that is not a command? Type in
nmcmp,all, instead of the
correct command, numcmp,all. Note that the keyword is black instead
of blue. This tells
you that PeDAL does not recognize the command.
6
13. Delete that line by clicking on the 10 to highlight the whole
line, then press the delete key
or use the Right Mouse Button and select "delete".
You have just done 50% of what you will use PeDAL for. Typing in
commands and using the
lookup and syntax prompting to help you be more accurate and
efficient.
Creating a Simple Macro We are going to now finish typing in the
macro. Don't worry about formatting and such right
now, we will come back and clean it up a little. Simply get used to
using PeDAL by typing in
these simple commands. Look at the syntax prompting, and the way
the program colors your
text and make sure that your keywords are all blue, numbers are
beige, and text values are
black.
l,1,6
l,6,5
l,2,3
l,3,4
7
et,1,solid92
mptemp
mptemp,1,0
mpdata,ex,1,,29e6
mpdata,prxy,1,,.27
esize,0.25/2,0
mshape,1,3d
mshkey,0
vmesh,all
eplot
2. Now that we have a macro we want to save it. PeDAL has the same
concept of
"working directory" as ANSYS Mechanical APDL. So we want to make
sure we go to
the directory we are going to run ANSYS in: Click on the "house"
icon to set the working
directory to a valid place you want to run ANSYS in:
3. Now click on the save icon, or use File>Save. Call the macro
ws1.mac
4. Start up ANSYS MAPDL in that working directory and type in ws1
to run the macro.
You should see this:
8
Debugging If we are honest with ourselves, we will admit that we
spend most of our time debugging our
commands. So PeDAL was written to make that easier.
1. If your macro worked, let's put some bugs in so we can practice
debugging
Change line 17 to be: vext,xll,,,0,0,4
Change line 19 to: wprota,0,90,0
Save your changes
2. Now run your macro again in ANSYS MAPDL
3. You will get an error. Unfortunately it does not tell you what
line it failed on. But if you
look at the output window you should see the some sort of warning
or error. If you
munged the VEXT command you will see:
*** WARNING *** CP = 13.307 TIME= 09:51:21
Specified range of 0 to 0 is not permitted. The VEXT command
is
ignored.
4. Once you have identified where your command failed, put a /eof
command on the line
before that command. PeDAL will mark /eof line and all lines below
it with a dark
9
5. Save and execute the macro. It will stop at the line before the
error command.
6. Now look at the command and try and figure out what is wrong.
You can type it into the
ANSYS command line, or you can change it in PedAL, copy that
line, and paste it into
the command line in ANSYS. Keep running the macro and fixing the
command till you
get it right.
Running Part of a File with CTRL+D The copy and paste in PeDAL work
like any other program, but when you paste some commands into
the ANSYS command input, they don't execute. You have to place the
commands in a file and run the
file. PeDAL provides a function for this by taking a selection of
text in a temporary file and putting a /INP
command for that file into the clipboard for pasting. If you ever
use *vwrite you will need to use this
option.
1. Select lines 1 through 17.
2. Press CTRL+D or use Edit>Copy to Input File from the
menu.
3. Now go to the ANSYS input window and CTRL+V for paste.
4. Now press return and ANSYS will read that tmp file. Note the
,,,,1 option. This tells the
program to put the contents of the file in the *.log file, not the
/inp command.
Using ANSYS Help with PeDAL The ability to quickly access the ANSYS
help manual from within PeDAL is the second most
useful feature in the program, just behind the syntax prompting.
You can access the full help,
search for a specific command, or get the command help for a given
command. In this section
we will do all three.
1. To search for a specific topic, simply type the word you want to
search on in the search
10
As you can see, it tells you the string it is searching on
and then the names of the sections it
found information in, along with the number of times the string is
used in that section. 1000
times in TB… that is a lot. If you click on the entry, it will take
you to that help page. All of the
hyperlinks in the ANSYS help still work, so you can explore from
there.
2. Click on TB and look around the help page.
3. Now click on "data table" near the top and it will go to section
3.1.
4. Click on the left pointing blue arrow on the browser tool bar to
go back to the TB
command.
5. Click on the left pointing blue arrow again to go back to the
list from the search.
6. To search on a specific command you can just put that command in
the search box. Or,
you can do it from the text editor.
Select "Search Help for "wprota"
7. You will see the same search result as if you typed "wprota"
into the help window. This
will show everywhere that the command is mentioned.
8. If you want the command help for that command, which is what you
want 90% of the
time, then do the same thing but choose "Show Command Help for
"wprota" instead.
Now the browser will go directly to that manual page. Try it.
Commenting Comments are an important part of any program, even an
APDL script. PeDAL has some nice
tools to make it easier to comment your macros, including some
automatic generation of
comments.
1. The first thing we want to do is a simple comment on a line.
Click in front of the f on the
first line and press enter, this creates a new first line. Then
type "! This is a comment"
The ! is a comment in APDL, and everything to the right of the ! is
not read by the
12
2. To comment out commands, you simply have to highlight the lines
you want
commented, and then click on the "Add Leading Comment…" icon: or
Right Mouse
Button and Select "Comment Selected Lines". Try it out by selecting
all the keypoint
creation commands (k,) and click on the icon or select the command
from the context
menu. The top of your macro should now look like this:
3. As you probably noticed, there is also a way to uncomment a
commented line. Select
the K commands again and click the "Remove Leading Comment…" icon:
or Right
Mouse Button to choose "Uncomment Selected Lines"
4. A very handy feature of PeDAL is the ability to automatically
comment a command, or all
the commands in a macro. To do this select one or more lines of
code and click the
Auto Comment icon, it looks like a lightbulb.
Select lines 18 through 23 (vext to et) and click on the icon
5. Click on Current Selection for Scope
6. For Comment Location you can have it above each command, to the
right of the
command with a fixed number of spaces, or aligned with the number
of spaces specified
as the minimum distance.
Chose Right of Command Column Aligned and set Padding Spaces to 2.
Click OK.
The result should look like this:
7. Click on the icon again and choose "Whole Document" and you will
see a description of
every command in the macro. That may be overkill but if non-experts
are using your
macro, it can be a real time saver.
8. Click the undo arrow (or Edit>Undo) twice to get rid of those
comments.
Aligning Large macros can get a bit messy, so PeDAL has some great
tools to clean things up.
1. Look at the K commands. Notice how the numbers don't line up and
it is hard to tell what
the X, Y, and Z components are for each one. To line everything
up:
Select all of the K, lines.
14
2. Click the "Align Command Fields" icon or Right Mouse Button and
chose "Align
Command Fields"
3. The "Remove any Whitespace" icon and "Compress Command Field"
context menu
picks get rid of any spaces if you want that.
Do so for the K commands
4. Now go and put the alignment back in.
Indentation PeDAL will automatically indent code that should be
indented, mostly *do loops and *if
statements. You can also do indentation on your own. For this
tutorial we will do a *do loop in
an *if statement.
1. Go to File>New Macro to create a new tab for our simple
*if/*do macro. We are going to
make a very silly macro that loops through nodes 1 to 100 and
assigns a displacement
of UX if it is an even numbered node, UY for the first half of the
odd numbered nodes,
and UZ for the second half of the odd numbered nodes.
2. Type the following commands in:
Nmnd=100.*do,i,1,nmnd
*if,mod(i,2),eq,0,then
d,i,ux,0.1
*else
*if,I,gt,nmnd/2,then
d,i,uy,.1
*else
d,I,uz,.1
*endif
*endif
*enddo
3. As you type, notice how PeDAL does the indentation for you.
Don't use tabs, just let the
program do it's thing.
15
4. Notice that PeDAL not only does the indentation, but it draws a
line connecting the start
and stop of a "group" and it provides tools that let you collapse
and expand a loop.
Click on the triangle for the most inner *if statement
(i,gt,nmnd/2).
5. Note that the triangle turns to ellipses (…) and lines are put
above and beyond the part
the collapsed. The first line is still shown to tell you what was
collapsed.
6. Click on the ellipses to show the whole *if statement
again.
7. Save the macro as "sillyloop.mac" We will use it in the next
section.
Hyperlinking Macros PeDAL looks in the same places that ANSYS does
for macros, and if it recognizes the name of
a macro it will treat it as a valid command, highlight it as such,
and create a hyperlink to the
macro file.
16
1. Click on the ws1.mac tab to go back to the original macro
2. At the bottom of the macro, type sillyloop. Note that PeDAL
highlights it as orange.
3. Hover your mouse over the line and it will behave like a
hyperlink.
4. Click on it, and the editor switches to sillyloop.mac.
Exporting Your Macro Once you are done with your macro you may want
to put it in a report or a website or
something. You can easily do this using the Export feature in the
File menu.
1. Go to File->Export
17
2. Note that you can save as RTF, TeX, and HTML. RTF can be read by
MS Word and
most other word processors, and the HTML is perfect for blog
postings and such. TeX,
well you must have a graduate degree if you use TeX…
3. Choose RTF and save the file as ws1.rtf.
4. Go to your working directory in your file browser and open up
the file. It should be a nice
copy of what you saw in PeDAL, nice and ready to use in your report
or Powerpoint.
Learning More In this short tutorial we covered only the basics of
PeDAL, with a few very useful advanced