HyperWorks 集成桌面环境下二次开发【四】----脚本实例
来源:互联网 发布:mac系统升级10.10下载 编辑:程序博客网 时间:2024/06/15 13:34
实例一 载入模型并查看模型应力
set proc_name "contour_stress"hwi GetSessionHandle sess 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 # Load model set model_id [post AddModel d:/samples/dyna/bumper_foam/d3plot"] post GetModelHandle mod $model_id mod SetResult "d:/samples/dyna/bumper_foam/d3plot" # Advance to first frame. page GetAnimatorHandle animator animator Next # Enable contour state and visibility mod GetResultCtrlHandle res mod ReleaseHandle res GetContourCtrlHandle contour_ctrl res ReleaseHandle contour_ctrl SetEnableState true post SetDisplayOptions "contour" true # Set result state 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" post Draw # Cleanup handles to avoid leaks and handle name collisions. 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 "--------------------------------------------"}
set proc_name "setTimeVector"hwi GetSessionHandle sess if {[catch { sess GetProjectHandle proj proj GetPageHandle page [proj GetActivePage] page GetWindowHandle win [page GetActiveWindow] if {[string match [win GetClientType] "Plot"]} win GetClientHandle plot set numcurves [plot GetNumberOfCurves] for {set i 1} {$i <= $numcurves} {incr i} plot GetCurveHandle curve $i curve GetVectorHandle curve_x x curve GetVectorHandle curve_time time if {![string length [curve_time GetValuesList]]} set max_x [lindex [lsort -real [curve_x GetValuesList]] end] curve_time SetType values curve_time SetValues [join [curve_x GetValuesList] ,] if {$max_x >= 1.00} set scale [expr [string length [expr int($max_x)]] * 10.00] curve_time SetScaleFactor [expr 1.00 / $scale] } } plot Recalculate plot Draw # Cleanup handles to avoid leaks and handle name collisions. curve_time ReleaseHandle curve_x ReleaseHandle curve ReleaseHandle } } else puts $logfile "Invalid Window Type: requires a plot window." } # Cleanup handles plot ReleaseHandle win ReleaseHandle page ReleaseHandle proj 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}
实例三 获取应力与位移的JEPG图像
set proc_name "jpeg_capture"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 # Load model set myfile "d:/samples/dyna/bumper_foam/d3plot" set model_id [post AddModel $myfile] post GetModelHandle mod $model_id mod SetResult $myfile # Advance to last frame. page GetAnimatorHandle animator animator SetAnimationMode "transient" animator SetCurrentStep [expr [animator GetNumberOfSteps]-1] # Enable contour state and visibility mod GetResultCtrlHandle res mod ReleaseHandle res GetContourCtrlHandle contour_ctrl res ReleaseHandle contour_ctrl SetEnableState true post SetDisplayOptions "contour" true post SetDisplayOptions "legend" true # Set to stress datatype set datatype "stress" 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 to displacement datatype set datatype "displacement" contour_ctrl SetDataType $datatype post Draw sess CaptureScreen "jpeg" "$tag-$datatype.jpg" # Cleanup handles to avoid leaks and handle name collisions. 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}
参考HyperWorks Desktop 手册,12.0版本。
- HyperWorks 集成桌面环境下二次开发【四】----脚本实例
- HyperWorks 集成桌面环境下二次开发【一】----基础
- HyperWorks 集成桌面环境下二次开发【二】----基础
- HyperWorks 集成桌面环境下二次开发【三】----数据层级结构
- HyperWorks 集成桌面环境下二次开发【五】----编写教程
- 在bitnami集成环境下进行redmine的二次开发--开发环境的搭建
- Linux环境下的脚本—shell(四)
- Linux环境下rman备份的实例脚本
- Liferay与Openfire集成 四 简单的二次开发
- C#环境下利用VS2017使用MapXtreme7.0.0开发桌面应用实例
- JVM调优系列(四)——集成环境下配置JVM参数
- 为原生WinPE 3.0集成桌面环境和常用软件
- FreaMarker入门教程,环境集成到使用实例
- Ubuntu下安装KDE桌面环境
- KDE 桌面环境下自定义快捷键
- ubuntu下安装xcfe4桌面环境
- ubuntu gnome桌面环境下创建快捷方式
- linux下的自由桌面环境
- W5100E01-AVR(W5100评估板)演示手册(二)
- (挑战编程_4_2)Stacks of Flapjacks
- sigcation 用法
- PHP 发送Http Header 404及301\302重定向
- RegOpenKeyEx在64位与32位系统编程注意事项
- HyperWorks 集成桌面环境下二次开发【四】----脚本实例
- J2EE中的13种技术规范
- php header跳转及函数详细说明
- (挑战编程_4_3)Bridge
- php 五大运行模式 CGI FAST-CGI CLI ISAPI APACHE模式
- 如何在IE下使用Firebug
- Serial Programming Guide for POSIX Operating Systems
- 使用DELETE ADJACENT DUPLICATE FORM特别注意啦
- java中的native关键字