ansys宏命令
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
友情链接帮助联系方式留言
首页Ansys案例Ansys技巧ansys新手I-deas Pro/Engineer UG学习Ansys专题Ansys 下载Ansys开发者论坛blog 搜索中心
apdl二次开发[翻译]
作者:面条| 发表日期:2005-3-16 | 繁体阅读|简体阅读|点击:670
Chapter 4. APDL as a Macro Language
4.1. What is an APDL Macro?
Y ou can record a frequently used sequence of ANSYS commands in a macro file (these are sometimes called command files). Creating a macro enables you to, in effect, create your own custom ANSYS command. For example, calculating power loss due to eddy currents in a magnetic analysis would require a series of ANSYS commands in the postprocessor. By recording this set of commands in a macro, you have a new, single command that executes all of the commands required for that calculation. In addition to executing a series of ANSYS commands, a macro can call GUI functions or pass values into arguments.
Y ou can also nest macros. That is, one macro can call a second macro, the second macro can call a third macro, and so on. Y ou can use up to 20 nesting levels, including any file switches caused by the ANSYS /INPUT command. After each nested macro executes, the ANSYS program returns control to the previous macro level.
The following is a very simple example macro file. In this example, the macro creates a block with dimensions 4, 3, and, 2 and a sphere with a radius of 1. It then subtracts the sphere from one corner of the block.
/prep7
/view,,-1,-2,-3
block,,4,,3,,2
sphere,1
vsbv,1,2
finish
If this macro were called mymacro.mac, you could execute this sequence of commands with the following single ANSYS command
*use,mymacro
or (because the extension is .mac)
mymacro
Although this is not a realistic macro, it does illustrate the principle.
This chapter provides information on the various ways you can create, store, and execute macros.
It also discusses the basic information you need to use APDL as a scripting language in creating macros.
4.2. Creating a Macro
Y ou can create macros either within ANSYS itself or using your text editor of choice (such as emacs, vi, or wordpad). If your macro is fairly simple and short, creating it in ANSYS can be very convenient. If you are creating a longer, more complex macro or editing an existing macro then you will need a text editor. Also, using a text editor allows you to use a similar macro or ANSYS log file as the source for your macro.
For any long, complex macro you should always consider either using a similar macro as a starting point or running the task interactively in ANSYS and using the resulting log file as the basis of your macro. Either method can greatly reduce the time and effort required to create a suitable macro.
4.2.1. Macro File Naming Conventions
Macros are a sequence of ANSYS commands stored in a file. Macros should not have the same name as an existing ANSYS command; ANSYS will execute the internal command instead of the macro. The following naming restrictions apply to macro files:
·The file name cannot exceed 32 characters.
·The file name cannot begin with a numeral.
·The file extension cannot contain more than eight characters (if you are executing the macro as if it were an ANSYS command it should have the extension .mac.)
·The file name or extension cannot contain spaces.
·The file name or extension cannot contain any characters prohibited by your file system and for portability should not contain any characters prohibited by either UNIX or Windows file systems. To ensure that you are not using the name of an ANSYS command, before creating a macro try running the file name that you wish to use as an ANSYS command. If ANSYS returns the message shown below, you will know that the command is not used in the current processor. Y ou should check the macro file name in each processor in which you plan to use the macro. (Y ou could also check if the macro file name matches any command listed in the online documentation; however, this method cannot locate the names of undocumented commands.)
Using the .mac extension allows ANSYS to execute the macro as it would any internal command. Y ou should avoid using the extension .MAC because it is used for ANSYS internal macros.
4.2.2. Macro Search Path
By default, ANSYS searches for a user macro file (.mac extension) in the following locations:
1. The ANSYSnn/docu directory.
2. The directory (or directories) designated by the ANSYS_MACROLIB environment variable (if defined) or the login (home) directory. This environment variable is documented in the ANSYS installation and configuration guide for your platform.
3. The directory designated by the $HOME environment variable.
4. The working directory.
Y ou can place macros for your personal use in your home directory. Macros that should be available across your site should be placed in the ANSYSnn/docu directory or some commonly accessible directory that everyone can reference through the ANSYS_MACROLIB environment variable.
·For Windows Me users: Y ou must designate the "home directory" and drive using environment