Making Pretty Plots in ANSYS Mechanical and Mechanical APDL

imageI was looking for some new images for our web page and all of the plots I had were pretty much screen grabs.  Not the high quality I was looking for.  And putting a picture of Angelina behind a mode plot probably won’t go over too well, or will go over too well and will distract everyone.  So I brought up the original models and started playing around trying to get a better quality image, and did pretty well.  And, needing an article for this week, I thought I’d share what I found. If you don’t use MAPDL, skip on down to the ANSYS Mechanical bit.

ANSYS Mechanical APDL

For my MAPDL plots I actually referred back to an old “The Focus” article I did in 2002. Yes, 2002.  You can go back to that article for the details but here are the important bits below:

  • Invest in a good image editing tool. If you are ultra-cheap, use the open source GIMP.  But Adobe Photoshop and Corel Paint Shop Pro are worth the investment.  With Paint Shop Pro having the price/performance advantage if you don’t already have Photo Shop
  • You don’t want to do screen grabs.  MAPDL has great plotting to file abilities and you want to use those.
  • Use the /show command to output high quality graphics and skip using the pixels on your screen. You have two great options:
    • Use /SHOW,PNG to tell MAPDL to write to a PNG file when you issue plot commands
      •   PNG is the best choice for smaller files and high resolution.  JPG may be more common but you will find that the images can be fuzzy, especially around edges.  Go PNG.

image

  • If you are really hard-core and you want an exact representation of you model that can be scaled, then do a /show,PSCR,,,8.  This makes an encapsulated postscript file.
    • If you don’t know what that is, we advice you don’t bother.
    • But if you do, pop it into Illustrator, group it and now you have a vector graphic you can scale, trim, edit and really do cool things with.
  • Get to know how to use the /ERASE, /NOERASE button for making multiple plots on a page.  You can use /win with the standard view commands to show results from different modes, different load steps, or if you get real clever, even different models.   Here is an example for plotting 4 different mode shapes:

! Plots first 4 modes
/erase
/win,1,ltop $/win,2,rtop
/win,3,lbot $/win,4,rbot
/view,all,1,1,1,1
/vup,all,Z
/angle,all,0
/dist,all,1.3
/focus,all,.2,.08,.05
/win,2,off $/win,3,off $/win,4,off
/plopt,info,0
/annot,delete
/TSPEC, 15,0.700,1,0,0
*dim,anx,,4
*dim,any,,4
*dim,frq,,4
anx(1) = -.98, .4, -.98, .4
any(1) = .01, .01, -.92,-.92
*do,i,1,4
set,1,I
*get,frq(i),mode,i,freq
plnsol,u,sum
/win,i,off
/win,i+1,on
/noerase
*enddo
/tlab,anx(1),any(1),Mode 1: %frq(1)% Hz/t
/tlab,anx(2),any(2),Mode 2: %frq(2)% Hz/t
/tlab,anx(3),any(3),Mode 3: %frq(3)% Hz/t
/tlab,anx(4),any(4),Mode 4: %frq(4)% Hz/t
/replot
/erase
anx=
any= 
image
  • Get rid of that black or blue-blue background by changing your screen to reverse video.
    • Through the GUI: PlotCtrls->Style->Colors->Reverse Video
    • Or put the following in a macro:
      /RGB,INDEX,100,100,100, 0
      /RGB,INDEX, 80, 80, 80,13
      /RGB,INDEX, 60, 60, 60,14
      /RGB,INDEX, 0, 0, 0,15

image

  • Use /TYPE to turn on slower, but higher quality hidden line removal
    • Default is z-buffer, which is fast but not a accurate
    • Precise is the best: /TYPE,,4 for hidden
  • Get smoother curved surfaces by increasing the number of facets on your polygons with /EFACET
    • /GRAPH,POWER is needed for it to work (default)
    • /EFACET,4 puts 16 (4/edge) faces on every element face.

image

  • Getting lots of pixels is the most important.  Just make a big file with lots of pixels by using /GFILE, 2400.
    • This gives you a file that is 2400 pixels tall
    •   You can then scale it down when you want to use it and get nice clean images.

There is a lot more you can do, like annotation, backgrounds, changing fonts, etc… But this covers the basics that everyone should know.  Take a look at the original article and help on the following command for more: /PLOPT, /EDGE, /TRIAD, /LIGHT, /DEV,FONT, /TEXTRE, /GFORMAT, /ANNOT.

ANSYS Mechanical

Now things get a little different. In that MAPDL is old, older than some of you reading this article, it has some wicked cool tools that were put in there from the days when many of us didn’t even have a color monitor.  Now the world is online and everything is about an 200pixel wide JPEG file to be uploaded onto Facebook, you don’t have as many options to get high quality images out of the Workbench interface.  But the good news is that the default image, is better than most of the high quality ones you have to work for to get out of MAPDL.

The Basics for ANSYS Mechanical

So, for a lot of cases, just doing a screen grab of your graphics window in ANSYS Mechanical is good enough. But if you want nicer plots, here are some suggestions:

  • If you are on Windows Vista or 7, then you need to turn of Windows Aero.  This is the transparent fancy-pants options for how windows are displayed. But the screen capture used in ANSYS Mechanical doesn’t work if it is turned on.  So if you are going to be doing Images or Animations, you need to turn it off.
  • Beyond the basic screen grab you should become familiar with the options under the little “New Figure or Image” Icon on the main icon bar

image

  • If you choose Figure or Image it adds a Figure or Image object under whatever object you have selected.
    • A figure is a 3D image that updates every time you click on it.  It stores the view settings when it is made, but you can rotate and zoom at any time.  It is a 3D picture
    • An image is a screen capture that is stored in the tree.  You can also import an image from your hard drive.
  • The easiest way to get a nice plot is to get what you want on the screen and use “Image to File”.
    • By default this will make a PNG file that is the resolution of the image on your screen.
  • For a higher quality image, make your graphics window bigger.  Remember, all ANSYS is doing is grabbing your screen and saving it to a file.
  • The default background is a bit annoying for plots, especially if you want just your model.  To turn it off go back to your project page and use Tools->Options->Appearance and set Background Style to Solid and Background color to white.
    • If you want to go old school and have white text and black background, you can set that here as well.

bg1bg2bg3

  • If you want to make an image that can float in your PowerPoint (no background, transparent) then I like to turn off all the decorations.  Do this by making sure your background is solid (white is usually good enough) and then go to View in the menu and uncheck Ruler, Legend, and Triad.
    • Once in PowerPoint, use the “Set Transparent Color” feature to set the white bits to clear.
    • Or, use you fancy image editing software to remove the background. (and put a cheesy one in if you want, as shown here:)
      image
  • Play with the options to get the image you want.  The contour style, if you want your elements shown or not, etc…
  • Another thing to know is how to change the default format for saving the images.  The default is PNG, which we recommend.  But if you need JPEG or BMP you can change it in Mechanical under  Tools>Options>Mechanical>Miscellaneous>Image>Image Transfer Type.

Getting Better Resolution on a Single Plot in ANSYS Mechanical

The above will work for most plots, but what to do if the image you get from screen grabs is just not good enough?  Maybe you are on a laptop and you can’t get the resolution you need. I especially find this true when I want to view my mesh.  This is the default I get with mesh on:

sc1

By using the Print Preview tab, I can get a very high resolution image:

  • Get the view you want in the graphics window.
  • Click on the Print Preview tab at the bottom of the graphics window
  • You should see what you saw on the screen.  Don’t panic.
  • On the Print Preview tool bar click on the little picture and choose High Resolution
  • It should update with a very nice high-rez image.
  • This is an HTML page, so you can right click on the image and copy it, or save it to disk.

preview

Getting Better Resolution on a Multiple Plots in ANSYS Mechanical

The above will work for a single image but can be a pain if you want a bunch.  For that we recommend that you leverage the Report Writer capability, even if you don’t want the report.  The Report Writer makes an HTML report of everything in your Model tree.  So if you put Figures in your tree, it will make those for you when you do a Report Preview, all in one nice little directory.  Here is how to use it:

  • For every plot you want, click on the object you want the plot of and then sue the “New Figure or Image” drop down to insert figures for every view you want.
    • Don’t use Images, remember those are just screen grabs and won’t give you better resolution.
  • When you are done, click on the “Report Preview” tab under the Graphics Window.
  • ANSYS Mechanical will go of and think for a while, then it will show you your HTML report.
  • You can cut and paste from the report if you don’t have a lot of images.
  • If you do have a lot of images, you will want to click on the Publish button
    • This brings up a dialog.  Don’t use the default Single file format, change it to “Page, Figures in Subfolder (*.html)” and pick a directory
    • they will be sitting in the Project_Files directory.
  • The default images are 600 pixels wide, which may be OK.  But if not, then you need to go into Options and tell ANSYS to make bigger, better images.
  • Go to Tools->Options->Mechanical->Report->Figure Dimensions
    • Set the Graphics Height and Width higher.  I like 1800 x 1500.  That is three time more than the default
    • You can get even more resolution by changing the Graphics Resolution to 2:1 or 4:1.  This makes the pictures 2 or 4 times larger.  But that can take a while…
  • Now go back and redo the Report Preview and you should see much larger images, and much higher quality.
  • To save to a folder, publish them.
  • Click on the images below to see them in their full resolution:

Figure0008
Default 600px wide image

Figure0008
1800px wide image

Figure0008
3600px wide image

Conclusion

And those are the high points.  Like everything else, the help is your friend and has much more detailed information.  And don’t be afraid to just try stuff out.  Explore the options and settings, make lots of images.  That worst thing that can happen is that you will create some files you need to delete.

We hope this will help you make pretty pictures for your next report so that project guy won’t grill you on stuff he really doesn’t understand…

3 Replies to “Making Pretty Plots in ANSYS Mechanical and Mechanical APDL”

  1. Please note: There was an error in the APDL macro for making four mode shape plots on one image. After the end of the *do-loop where the annotation giving the mode number and frequency completes, you need to do a /replot. In older versions of ANSYS this was not needed but it looks like it is now. I’ve updated the code in the article to be correct. – Eric

  2. How do you get 3600px or larger pics in Ansys?

    Tools->Options->Mechanical->Report->Figure Dimensions
    did not work, I typed in the numbers like 3600 4000 6000 10000 but it looks like above 2400px, whatever the number I typed in, the size of the resulting file does not change, i.e. the resolution does not increase.

    The command manual says /gfile has an upper bound of 2400 for z buffered pics. What is it exactly? I was trying to create bitmap pics.

    Any help is greatly appreciated.