HyperView二次开发实例2

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
}

工程师必备
- 项目客服
- 培训客服
- 平台客服
TOP
