Macros

  • p_protec.mac

    Chris Kennedy (Think PEAK, Inc.)

    Used as a "wrapper"for SAVE and RESUME in Toolbar, so one doesn't inadvertantly overwrite stuff in memory.

  • para-2.mac

    Mike Rife (CSI)

    Creates parabola, ellipse, or hyperbola.

  • peri3d.mac

    (EMI)

    This is an ANSYS macro that creates periodic boundary conditions for a 3D model. It is a modified version of Peri.mac that automatically determines the DOF per node and active coordinate system, therefore it can be used to couple structural symmetry model boundaries as well as FLOTRAN periodic boundaries.

  • picker.mac

    Chris Masterson (University of Toronto)

    A while back I asked Bill Bulat for a pointer to a macro that could be used for meshing skin depths. He gave me some good pointers. I have since been working on a skin depth macro myself. I now have a first working beta". It is currently pretty crude since I'm relatively new to ANSYS, my geometry is pretty simple and the expansion algorithm I worked out is very simple. It will only mesh a line of rectangular prisms oriented with the current coordinate system. The end result is something similar to what a straight VSWEEP command could accomplish but with the difference that the user can specify exactly the thickness of the skin depth (or boundary layer if it suits) and how many layers of mesh should be contained in that skin depth. Suits my purposes for now so I thought that maybe somebody else might find a use as well. There are actually three macros: skin.mac - the main macro, and sorter.mac and picker.mac that are called from the main macro. The other caveat I guess is to mention that I wrote them for Ansys 5.5 and so some of the command names may be changed or obsolete (which includes jumping to a label which was already technically obsolete in 5.5) in newer versions."
    "I posted some skin depth meshing macros to the Ansys egroup that you reproduced on your ansys.net page. Since then I have updated the macros significantly to make them more usable and a lot less buggy. The macro is now able to mesh full planes of rectangular prisms, instead of just a line of prisms. With the use of an extra coordinate system I use it to expand the mesh in both directions away from the surface of interest. The macros are now updated to Ansys version 5.6 as well (and in fact won't work in 5.5 due to VSWEEP no longer requiring source and target areas). Just thought I would send the new improved versions to save frustration if anyone ever uses them."

  • plot_tag.mac

    Mark Tate (Hamilton Sundstrand)

    This macro will tag your plots with directory and jobname.

  • plrv.mac

    Rick Fischer (Marconi Communications)

    "This macro reduces the number of vectors plotted so that a velocity vector plot on a model with a fine mesh will be more ledgible. It works great for plotting velocity in the middle of a flat rectangular duct on a plane of symmetry. It creates a grid of points in the active coordinate system, finds an element that contains that point, and plots a velocity vector from that element's centroid."

  • plvln.mac

    Mike Yaksh (NAC Int'l)

    Macro for displaying vector plots with element outline overlay.

  • pressure.mac

    Imad Tabsh (CompuSIM Inc.)

    Applies pressure from an equation onto a node or an area. User must modify macro with their own equation.

  • pringet.mac

    Mike Yaksh (NAC Int'l)

    "This macro computes the principle stresses and SI for the maximum node number or for the stress input by the input arguements."

  • prnwp.mac

    James Kosloski (CAEAI)

    "Macro to align working plane with principal stress directions at a node"

  • psdout.mac

    Jeff Strain (PADT)

    "psdout.mac retrieves PSD data, in G^2/Hz, at picked nodes and stores them as variables in the Time History postprocessor as well as the array parameter PSDDATA. PSDDATA excludes data for modes lying outside the input PSD spectrum. The user also has the options of plotting the PSD curves and/or exporting the data to the text file, psddata.txt.
    Usage: psdout,dir,plot,list where dir = 'x', 'y', or 'z' (defaults to 'x'); plot = 1 to plot the PSD curves in ANSYS (defaults to 0); and list = 1 to export the data to psddata.txt (defaults to 0).
    Acceleration results (load step 5) must be available for this macro to work."
    Example output plot as PNG file

  • put_amp.mac

    Mike Yaksh (NAC Int'l)

    Applies J to selected elements for a specified current input (A). Model is assumed to be in SI units.

  • qclear.mac

    Rod Scholl (PADT)

    Does a /CLEAR without prompting the user for an OK

  • qzmulti.mac

    Peter Budgell (Innovative Steam Technologies)

    The following APDL code can do a stress plot for a Working Plane slice on top of a capped hidden display of the underlying elements. You will need to change the two /TYPE commands if you want to use a Z-Buffer approach. You may want to add a /TYPE command at the end to change back to a conventional hidden surface method. You have to be in /POST1 before calling this macro, and have defined the position of your Working Plane inside the body of your model. Customize as you wish.

  • random.mac

    Jeff Strain (PADT)

    "Performs PSD base excitation analysis on a component in units of G^2/Hz.
    Execute random,1 to perform a modal analysis prior to the PSD analysis. Execute random with no arguments to run the PSD solution only.
    Apply constraints before running this macro"

  • randseed.mac

    Stefan Reh (ANSYS, Inc.)

    "All random number generators are only pseudo-random number generators. They use what is called a "seed"value to calculate a random number. The result is only pseudo-random because with the same seed value you will always end up with the same "random"number. So whenever you start ANSYS it initializes the seed value. If you start generating random numbers then you will always get the same sequence of "random"numbers. The solution to this problem is to randomize the seed value itself using the system-time. Enclosed is the macro "randseed"that will exactly do that. You will get "real"random numbers after you run "randseed". You might want to run this macro every time before you start with your random number generation. You can also include the macro in your "start.ans"procedure so it will be executed each time you start ANSYS."
    It effectively randomizes the seed by executing the RAND an arbitrary number of times.

  • rcs2ics.mac

    Mark Troscinski (ANSYS, Inc.)

    "Macro RCS2ICS transforms FLOTRAN velocities, computed in a rotating coordinate system (or frame of reference), into an inertial coordinate system, for post-processing purposes."

  • rcyl.mac

    Steve Hale (CAEAI)

    "A macro has been developed that calculates the actual radial and tangential displacements for a large rotation analysis in ANSYS. The macro, named RCYL.MAC , stores the actual radial and circumferential displacements in the following results quantities:
    EPTOT,XY = radial displacement
    EPTOT,YZ = circumferential displacement
    The macro is valid for up to 180 degrees of rotation and it correctly handles the case when a node rotates from one quadrant to the next. Full Graphics mode must be used when plotting these results because a *VPUT command is used in the macro."

  • readsi.mac

    David Gross (Dominion Engineering, Inc.)

    Example of a macro for stress intensity extraction. Dumps results of PRSECT to file, then *VREADs results into array.

  • reassign.mac

    Sheldon Imaoka (CSI)

    Example of reassigning matrix scratch files to another directory. For this example, I also differentiate between the platform type when specifying a scratch directory since Windows and UNIX file systems are assigned differently.
    Requires jobname macro.

  • reformat.mac

    Sheldon Imaoka (CSI)

    Provides a longer format listing for /POST1 (PRxxxx commands) with longer "pages". Makes for nicer-looking listings to import into third-party spreadsheets or programs such as Excel or Tecplot.

  • renam.mac

    John Swanson (SAS, Inc./ANSYS, Inc.)

    Renames files in working directory. For example, using "renam,'tif',_1"renames all TIF files in working directory and adds prefix "_1". Useful to rename graphics files. (Note: At 5.6.1, the undocumented command /DIRGET which this macro uses does not work on Windows and will result in an abort.)

  • rfor_total.mac

    Adam Shinbrot (Zimmer Spine)

    "For a selected nodal set, macro creates vector r_f of dimension arg1 x 1 and fills it with successive values of reaction forces in y for successive time steps, the total number of which is specified by arg1.
    "This macro assumes ultimate time step is number 1; this is easily changed, however."

  • rotv.mac

    John Crawford (Honeywell)

    A macro to rotate the currently selected volumes about an axis.

  • round.mac

    Gordon May (Rolls Royce Compressor Key System)

    Macro to round a parameter to a specified number of digits.

  • rparea.mac

    rparea.mac

  • sasel.mac

    Sheldon Imaoka (ANSYS, Inc.)

    Macro used to select areas based on the value of the area itself (=length^2). Can be used to select all areas of a certain surface area or a range of surface area (with tolerance).

  • scopy.mac

    Dave Rea (ANSYS, Inc.)

    Macro used to copy a meshed sector to a full 360 degree model. Copies meshed solid model and merges nodes (can also edit to merge keypoints). Also, an example file is supplied.

  • select_hexpyra.mac

    SELECT_HEXPYRA

    Simple example to unselect tetrahedral and wedge-shaped SOLID164 degenerate elements, leaving only hexahedral and pyramid SOLID164 selected.

    While this macro has limited usefulness by itself, it can be used as an example of selecting certain element shapes by nodal connectivity - very useful if you have a single element type but multiple degenerate element shapes and want to differentiate between them in your model.

  • selloc.mac

    Don Shaffer (Siemens Westinghouse Power Corp)

    "This is a utility tool to speed up selection of model entities by location."Please read the comments in the macro file for more details on usage.

  • seqv_max.mac

    Adam Shinbrot (Zimmer Spine)

    "For a selected nodal set, macro creates vector s_eqv of dimension arg1 x 1 and fills it with successive values of SEQV (Von-Mises stress) max for successive time steps, the total number of which is specified by arg1.
    "This macro assumes ultimate time step is number 1; this is easily changed, however."

  • setLegend.js

    Al Hancq (ANSYS, Inc.)

    "The macro below will set the legend of the current result in DesignSpace. (Note that this and any legend setting will get wiped out after a resolve)"

    put the contents below into a script file (like setLegend.js), setting the legend min/max as desired
    select your desired result.
    run this macro via Tools->Run Macro

    "You can make this macro to be more elaborate such as walking down the tree and setting all result legends at once."

    "I have verified this macro in DesignSpace 6.0.1 but it should work in DesignSpace 6.0 as well."

  • setScale.js

    Sheldon Imaoka (ANSYS, Inc.)

    "Attached is a quick hack of a macro to change the scaling for the deformed shape in DesignSpace v6. Edit the file and put in the scale factor you want, then use "Tools > Run Macro..." to run this.
    Please note that your Results toolbar will not be updated with this macro, and it will show whatever you had previously (like "0.5:1 Automatic"). What I'd suggest doing is changing to 'undeformed' and then running this macro, so you know that it's your own specified scale factor, even though the Results toolbar says 'undeformed.'"

  • sfmap.mac

    (CAEAI)

    "This macro is used to map pressure from a CFD mesh onto a structural mesh. The point XYZ locations from the CFD analysis must exist in an array called cfdxyz(npts,3). A corresponding array called "cfdpres"must be exist also. This array contains the pressure values corresponding to the point locations."
    Useful example of the use of *MOPER,,,MAP.

  • shownres.mac

    Hursha Narayan (Robert Bosch Corporation)

    "This macro takes an result parameter as input and shows the value at the corresponding group of nodes selected in the model."

  • siresume.mac

    Sheldon Imaoka (CSI)

    Use this for the RESUM_DB abbreviation in the Toolbar to prevent accidental resuming (which clears contents of current database). This macro will not prompt user for confirmation is database is blank. Otherwise, it will prompt user to verify that he/she wants to resume.

  • skin.mac

    Chris Masterson (University of Toronto)

    A while back I asked Bill Bulat for a pointer to a macro that could be used for meshing skin depths. He gave me some good pointers. I have since been working on a skin depth macro myself. I now have a first working beta". It is currently pretty crude since I'm relatively new to ANSYS, my geometry is pretty simple and the expansion algorithm I worked out is very simple. It will only mesh a line of rectangular prisms oriented with the current coordinate system. The end result is something similar to what a straight VSWEEP command could accomplish but with the difference that the user can specify exactly the thickness of the skin depth (or boundary layer if it suits) and how many layers of mesh should be contained in that skin depth. Suits my purposes for now so I thought that maybe somebody else might find a use as well. There are actually three macros: skin.mac - the main macro, and sorter.mac and picker.mac that are called from the main macro. The other caveat I guess is to mention that I wrote them for Ansys 5.5 and so some of the command names may be changed or obsolete (which includes jumping to a label which was already technically obsolete in 5.5) in newer versions."
    "I posted some skin depth meshing macros to the Ansys egroup that you reproduced on your ansys.net page. Since then I have updated the macros significantly to make them more usable and a lot less buggy. The macro is now able to mesh full planes of rectangular prisms, instead of just a line of prisms. With the use of an extra coordinate system I use it to expand the mesh in both directions away from the surface of interest. The macros are now updated to Ansys version 5.6 as well (and in fact won't work in 5.5 due to VSWEEP no longer requiring source and target areas). Just thought I would send the new improved versions to save frustration if anyone ever uses them."

  • skndpth.mac

    Bill Bulat (CSI)

    Used to calculate skin depth. Prompts for resistivity, relative permeability, and frequency.

  • slicepln.mac

    Don Shaffer (Siemens Westinghouse Power Corp)

    "This macro moves the working plane origin to the specified keypoint and orients it with wz normal to the specified cartesian axis with x=1,y=2 and z=3."

  • sort2d.mac

    Ashok K. (EACoE, Bangalore)

    Ansys macro to sort a given numeric array (2d)

    I usually get all the nodal coordinates into an array (call it NodeInfo) with node numbers in col 1; X,Y and Z coords in columns 2, 3 and 4 respectively.

    Then lets say I want to sort by the Z- coord followed by the X-coord and then the Y-coord I call the macro

    sort_by_cols, 'NodeInfo', 4,2,3

    The tolerance is something which you may or may not need. Depends on your application. If you just want to compare upto full decimal accuracy leave the tolerance value at zero.