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