« 采用Bootstrap主题 | Home | 一次未遂的手机病毒攻击 »

July 28, 2015

使用Tcl语言进行Hypermesh二次开发

Hyperworks是Altair公司的有限元分析软件,该软件包括了前处理、求解器、后处理完整的模块,由于功能强大,在CAD/CAE领域得到了广泛的应用。在有限元分析中,前处理所花费的时间可能多达80%~90%,而网格划分是其中的主要工作。Hypermesh作为Hyperworks的前处理模块,因对第三方求解器接口友好被大量应用。

Hypermesh使用Tcl/Tk语言作为二次开发的工具。对Hypermesh的二次开发在面对大量重复性工作的时候可以很大程度的提高工作效率。

使用Tcl/Tk进行二次开发的过程很简单:在Hypermesh的默认工作路径下有一个文件Command.cmf,这个文件记录了每个操作的动作。在打开Hypermesh之前,删除这个文件。启动Hypermesh,这个文件会被重新生成。执行一个需要重复操作的动作周期,Command.cmf就记录了操作过程。编辑这个文件,将其中的括号和逗号全部用空格替代,将文本另存为以tcl为后缀的文件。具体的过程可参照《Tips & Tricks: Fun With The Command.cmf File》

以下是一个将Hypermesh网格按照component分组逐个输出为nastran格式的脚本,输出文件名为component名字,因此需要注意不要有特殊符号。代码中的tmpl和savedir变量根据实际进行修改。

set lst_comp [hm_entitylist comps name] 
set tmpl "[hm_info -appinfo SPECIFIEDPATH TEMPLATES_DIR]/feoutput/nastran/general" 
set savedir "D:/work/Temp/Hm" 
*displaynone 
foreach comp_name $lst_comp { 
    *displaycollectorwithfilter components "on" $comp_name 1 0  
    *retainmarkselections 0  
    *entityhighlighting 1  
    *createstringarray 0  
    *feoutputwithdata $tmpl $savedir/$comp_name.bdf 0 0 0 1 0  
    *displaycollectorwithfilter components "off" $comp_name 1 0  
} 
*displayall 

Monthly Archives

About this Entry

This page contains a single entry by vincent published on July 28, 2015 10:38 PM.

采用Bootstrap主题 was the previous entry in this blog.

一次未遂的手机病毒攻击 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.