加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

HyperView二次开发实例2

(2016-09-16 18:50:55)
标签:

hyperview二次开发

hyperworks

tcl/tk

分类: HyperMesh技术及二次开发

HyperView二次开发实例2

以下Tcl脚本用于在HyperView中自动截图。

 

#设置名称

set proc_name "jpeg_capture"

#获得Session Handle

hwi GetSessionHandle sess

 

if {[catch {

 

 # Get a post object handle

 sess GetProjectHandle proj

 proj GetPageHandle page [proj GetActivePage]

 page GetWindowHandle win [page GetActiveWindow]

 win SetClientType "Animation"

 win GetClientHandle post

 #以上几行获得各级Handle

 # 加载模型和结果

 set myfile "d:/samples/dyna/bumper_foam/d3plot"

 set model_id [post AddModel $myfile]

 post GetModelHandle mod $model_id

 mod SetResult $myfile

 

 # 指定显示最后frame的结果

 page GetAnimatorHandle animator

 animator SetAnimationMode "transient"

 animator SetCurrentStep [expr [animator GetNumberOfSteps]-1]

 

 #设置结果显示

 mod GetResultCtrlHandle res

 mod ReleaseHandle

 res GetContourCtrlHandle contour_ctrl

 res ReleaseHandle

 contour_ctrl SetEnableState true

 post SetDisplayOptions "contour" true   #显示云图

 post SetDisplayOptions "legend" true    #显示legend

 

#显示结果类型

 contour_ctrl SetDataType $datatype

 contour_ctrl SetShellLayer "max"

 contour_ctrl SetDimensionEnabled shell true

 contour_ctrl SetDataComponent shell "P1"

 contour_ctrl SetDimensionEnabled solid true

 contour_ctrl SetDataComponent solid "P1"

 post Draw

#自动截图

 sess CaptureScreen "jpeg" "$tag-$datatype.jpg"

 

#显示位移

 set datatype "displacement"

 contour_ctrl SetDataType $datatype

 post Draw

#自动截图

 sess CaptureScreen "jpeg" "$tag-$datatype.jpg"

 

#释放Handle

 contour_ctrl ReleaseHandle

 post ReleaseHandle

 page ReleaseHandle

 sess ReleaseHandle

         

} result]}

 # Error handling

 set msg "Error occured running $proc_name\n\n[sess GetError]"

 tk_messageBox -title "Error running script" -message $msg

}

 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有