HyperView二次开发实例1

HyperView二次开发实例1

以下Tcl脚本用于在HyperView中加载和显示结果云图。

 

#设置名称

set proc_name "contour_stress"

#获得Session对象,名称为sess

hwi GetSessionHandle sess

 #catchC++的类似,用于处理异常

if {[catch {

 hwi GetSessionHandle sess

 sess GetProjectHandle proj

 proj GetPageHandle page [proj GetActivePage]

 proj ReleaseHandle

 page GetWindowHandle win [page GetActiveWindow]

 win SetClientType "Animation"

 win GetClientHandle post

 win ReleaseHandle

 #以上几行获得各级对象,winwindows对象

 # AddModel在窗口中添加对象,对象的id号存储给model_id

 set model_id [post AddModel d:/samples/dyna/bumper_foam/d3plot"]

#得到Model Handle

 post GetModelHandle mod $model_id

#给这个模型设置结果,不同求解器对于不同的结果类型

 mod SetResult "d:/samples/dyna/bumper_foam/d3plot"

#得到Animationor Handle  

 page GetAnimatorHandle animator

#指定frame

 animator Next

 

 #得到result Handle

 mod GetResultCtrlHandle res

 mod ReleaseHandle

#得到ContourCtr Handle

 res GetContourCtrlHandle contour_ctrl

 res ReleaseHandle

 contour_ctrl SetEnableState true

#设置结果显示方式为云图显示

 post SetDisplayOptions "contour" true

 

 #设置结果类型为 stress

 contour_ctrl SetDataType "stress"

 contour_ctrl SetShellLayer "max"

 contour_ctrl SetDimensionEnabled shell true

 contour_ctrl SetDataComponent shell "P1"

 contour_ctrl SetDimensionEnabled solid true

 contour_ctrl SetDataComponent solid "P1"

 

#设置完成后需要通过draw生成

 post Draw

 

#释放handle

 contour_ctrl ReleaseHandle

 post ReleaseHandle

 page ReleaseHandle

 sess ReleaseHandle

         

} result]}

 # Error handling

 puts $logfile "----- Error occured running $proc_name -----"

 puts $logfile "[sess GetError]"

 puts $logfile "--------------------------------------------"

}  

 

登录后免费查看全文
立即登录
App下载
技术邻APP
工程师必备
  • 项目客服
  • 培训客服
  • 平台客服

TOP

3
2