Patran二次开发工具PCL系列教程之7
二次开发工具系列教程之PPT课件

7-1
Icons
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
7-2
Icon Example:
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
Input:
widget
parent
Parent widget ID. Must be a frame, a form, or a modalform.
string
callback Name of PCL function called for an event in this
widget. The
Function: Creates an icon item widget to be used as a child of a menu, or switch widget.
Input:
widget switch.
parent
ID of the parent widget. Must be a menu, menubar, or a
Name of the file containing the hex information that is used
logical
toggleable Value used only for menu items; ignored if the item is not a
menu item. If TRUE,
function must be in the class in
which the widget is created. Use "" if
patran使用技巧

分享patran使用中的一些技巧patran技巧[分享]为何我的FEM选单中不会出现Hybrid Mesh<Patran> 为何我的FEM选单中不会出现Hybrid Mesh?-->请在系统的环境变数中增加以下变数:PATRAN_USE_HYBRID_SURFACE_MESHER值设定为TRUE ,这样在surface mesh处, 除了Iso Mesh跟Paver Mesh外,就会看到另外一个Hybrid Mesh的选项[分享]MSC多解析任务批处理的方法如果仅有一台机器可以进行解析运算,有时候任务比较多的时候会时间来不及.提交模型让机器计算之后只能在旁边傻看着,什么也做不了. 其实有一种比较好一点的方法.可以用批处理文件让机器连续自动处理,下班时运行披处理文件,第二天早上来看结果.方法如下:比如有3个模型,S1.MOD,S2.MOD,S3.MOD1. 分别将上诉3个模型导出为DAT文件2.建立批处理c:\mscvn4w2002\solver\bin\nastran S1.datc:\mscvn4w2002\solver\bin\nastran S2.datc:\mscvn4w2002\solver\bin\nastran S3.dat3. 双击4. 下班5. 上班6. 导入解析结果.[转帖]PATRAN的一些小技巧1、在Patran里如何Move 一组Points 的位置, 而不改变这组Points 的ID 编号? Group/Transform/Translate的功能,这样不但编号不会变, 连property跟边界条件都会保留2、Patran如何执行多次Undo?所有Patran的操作步骤, 都记录在最新的一个patran.ses.xx中,如果需要多次undo, 可以刪除最后不需要的步骤指令行,再利用File -> Session -> Play 的方式, 执行改过的patran.ses.xx ,这样可以无限制的undo。
用MSC_Patran的PCL二次开发用户界面

文章编号:167127953(2002)03220203收稿日期:2002203228作者简介:唐友宏(19802),男,硕士在读用MSC.Patran 的PC L 二次开发用户界面唐友宏 陈宾康(武汉理工大学交通学院,武汉430063)摘 要:在对MSC.Patran 进行二次开发时,通常要自己编写自定义的图形界面,以实现开发者所需的一些特殊功能,结合某些用户界面,说明利用PC L 语言进行二次开发用户界面的过程和应注意的问题。
关键词:MSC.Patran ;PC L 语言;用户界面;二次开发中图分类号:U662.9 文献标识码:AAbstract :When y ou use MSC.Patran to ,y ou usually need to com pile self -defined graphical inter faces ,in order to achieve s ome special function needed by developer.This paper shows the process of using PC L language to develop user in 2ter face and the problems needed to be attention by using the exam ple of s ome user inter face.K ey w ords :MSC.Patran ;Patran C ommand Language ;User inter face ;Redevelopment1 引言MSC.Patran 是世界公认最佳的集几何访问、有限元建模、分析求解及数据可视化于一体的新一代框架式软件系统,通过其全新的“并行工程概念”和无与伦比的工程应用模块,将世界所有著名的C AD/C AE/C AM/C AT (测试)软件系统及用户自编程序自然地融为一体。
Patran二次开发步骤

1.******在Patran下挂下拉菜单******通常我们不修改init.pcl文件,启动init.pcl时而会执行附带的启动文件p3prolog.pcl 和p3epilog.pcl。
如果这些文件存在,就会在init.pcl启动前后装载p3prolog.pcl(启动前)和p3epilog.pcl(启动后),所以这两个文件是我们插入自定义命令的好地方。
!!PATH!!LIBRARY!!INPUT在Patran安装目录下修改p3prolog.pcl,加入如下命令,例如:!!input mymenu.pcl #装载菜单文件ui_exec_function("mymenu","init") #当且仅初始化一次!!input plateform.pcl #装载对话框文件2.******** 下拉菜单程序编写*********CLASS exerciseFUNCTION init() /*初始化菜单*/WIDGET menubar,menu,item1,item2,item3 /*定义控件变量*/menu = uil_primary.get_menubar_id() /*获取主菜单ID*/menubar=ui_menu_create(menu,"exercise_menu","有限元分析") /*添加菜单*/ item1=ui_item_create(menubar,"ex_1","计算",FALSE) /*添加子菜单*/ item2=ui_item_create(menubar,"ex_2","导入文件",FALSE) /*添加子菜单*/ item3=ui_item_create(menubar,"ex_3","结束",FALSE) /*添加子菜单*/ END FUNCTIONFUNCTION exercise_menu(item_name) /*菜单各项的响应函数*/STRING item_name[]SWITCH(item_name)CASE("EX_1")write("Plate with a hole creating function")ui_exec_function("plateform","init")plateform.display()CASE("EX_2")write("cross pipes creating function")CASE("EX_3")write("slot modeling function")END SWITCHEND FUNCTIONEND CLASS3.*******弹出对话框程序编写*******#include "appforms.p"CLASS plateForm/*定义控件变量*/CLASSWIDE WIDGET form_id,dataBox1,dataBox2,dataBox3,@apply_button,cancel_button,delete_button/*初始化对话框,必要的函数*/FUNCTION init()real x_loc,y_loc/*创建对话框窗体ui_form_create(callback,x,y,position,width,height,label,[unused])*/form_id=ui_form_create("",FORM_X_LOC,FORM_Y_LOC,"UL",FORM_WID_SML,FOR M_HGT_FULL,"PLATE WITH A HOLE","")/*创建图标*/x_loc=FRAME_WID_SINGLE/2.-200*PIXEL_WID/2.+FORM_L_MARGINy_loc=FRAME_T_MARGIN+INTER_WIDGET_SPACE/*ui_labelicon_create(parent,callback,x,y,label)*/ui_labelicon_create(form_id,"",x_loc,y_loc,"platehole.icon")y_loc+=200.*PIXEL_HGT+DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACE/*创建输入文本框ui_databox_create(parent,callback,x,y,label_length,box_length,width,height,label,value,label_abo ve,datatype,num_vars)*/dataBox1=ui_databox_create(form_id,"",FRAME_L_MARGIN,y_loc,SINGLE_SPACE*5.0, DBOX_WID_SINGLE*0.6,"r=",2.,FALSE,"REAL",1)y_loc+=DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACEdataBox2=ui_databox_create(form_id,"",FRAME_L_MARGIN,y_loc,SINGLE_SPACE*5.0, DBOX_WID_SINGLE*0.6,"w=",5.,FALSE,"REAL",1)y_loc+=DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACEdataBox3=ui_databox_create(form_id,"",FRAME_L_MARGIN,y_loc,SINGLE_SPACE*5.0, DBOX_WID_SINGLE*0.6,"h=",5.,FALSE,"REAL",1)y_loc+=DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACE*2/*创建“应用”按钮ui_button_create(parent, callback, x, y, width, height, label, [unused], highlight)*/apply_button=ui_button_create(form_id,"apply_cb",BUTTON_HALF_X_LOC1,y_loc,BUT TON_WID_HALF,0,"应用",TRUE,TRUE)/*创建“取消”按钮*/cancel_button=ui_button_create(form_id,"cancel_cb",BUTTON_HALF_X_LOC2,y_loc,BU TTON_WID_HALF,0,"取消",TRUE,FALSE)y_loc+=DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACE/*创建“删除”按钮*/delete_button=ui_button_create(form_id,"delete_cb",BUTTON_HALF_X_LOC1,y_loc,BUT TON_WID_HALF,0,"Delete",TRUE,FALSE)y_loc+=BUTTON_DEFAULT_HGT+FORM_B_MARGIN+INTER_WIDGET_SPACE ui_wid_set(form_id,"HEIGHT",y_loc)END FUNCTION/*窗体显示,必要的函数*/FUNCTION display()ui_form_display("plateForm")END FUNCTION/*“应用”按钮响应处理函数*/FUNCTION apply_cb()real r,w,hui_wid_get(databox1,"V ALUE",r)ui_wid_get(databox2,"V ALUE",w)ui_wid_get(databox3,"V ALUE",h)ui_form_hide("plateform")ui_writec("r =%f,w=%f,h=%f",r,w,h)END FUNCTIONFUNCTION cancel_cb()ui_form_hide("plateform")END FUNCTIONFUNCTION delete_cb()ui_form_delete("plateform")END FUNCTIONEND CLASS4.C++文件编译处理例如:d:\msc\patran2001r2\bin\cpp -id:/msc/patran2001r2/customization c:/uillist.pcl c:/uillist.cpp 5.编程格式介绍转行继续符:@分号分隔符:同C++:“;”注释多行:/*……*/注释单行:“#”或者“$”计算表达式说明:用“`”(数字1键左边的那个键)例如:Angle:`360/5`,或者用WRITE(10+20)变量和常量Integer(整型),Real(实数),Logical(TRUE和FALSE),String,Widget(控件,有个常量WIDGET_NULL)变量的生命周期Global 全局Local 在函数内,本地Static 静态,patran退出就消失ClassWide 对一组函数可见,patran退出就消失6.指令文件管理!! input file.pcl #编译连接file.pcl,并将函数调入patran!!compile file.pcl into xxx.plb #编译file.pcl,并存入plb库中!!library xxx.plb #将plb文件调入patran!!path Directory #指定打开文件的目录!!Trace option pcl #执行确认!!Debug option #保存注释!!options option #pcl环境设置!!size code newsize #为编译代码区设置大小!!clear global name #删除全局变量定义!!clear function name #删除函数定义。
基于MSC_Patran二次开发的结构参数化建模及其集成开发环境

文章编号 167127953(2005)02204217收稿日期 2004212208作者简介 何祖平(1975-),男,硕士,助理工程师基于MSC.Patran 二次开发的结构参数化建模及其集成开发环境何祖平 王德禹上海交通大学船舶海洋与建筑工程学院 上海 200030摘 要 应用PC L 语言结合会话文件对MSC.Patran 平台进行二次开发,通过梁结构建模与分析的参数化,提高了工作效率,同时也促进了建模和计算精度的改善;通过在M icros oft Visual C ++ 6.0的编辑器中加载外部工具的方法,将PC L 开发环境与VC 编辑器集成,充分利用VC 编辑器的强大功能,使PC L 程序的开发更为方便快捷。
关键词 船舶结构 参数化建模 MSC.Patran PC L 语言 会话文件 二次开发 集成开发环境中图分类号 U661.42 文献标识码 AParameterized m odeling based on MSC.Patran andits integrated development environmentHE Zu 2ping WANG De 2yuSchool of Naval Architecture ,Ocean and Civil Eng. Shanghai Jiaotong University Shanghai 200030Abstract The PC L language combined with the session file of MSC.Patran is applied for the parameterized m odeling and analysis for structures ,which can im prove the efficiency with the m odeling and analysis precision enhanced.The tech 2nique can be further popularized for analysis of ship and other structures.This paper als o introduces a method to integrate PC L development environment into VC editor by loading the exterior tools.The power ful ability of VC editor is able to make the PC L development m ore convenient and efficientK ey w ords ship structure parameterized m odeling MSC.Patran PC L language session file second 2time de 2velopment integrated development environment 随着造船技术与航运市场的发展,船舶建造向大型化和经济化方向发展,越来越多的船舶超越了现行有关规范的规定,需要利用有限元直接计算的手段来评估船舶的安全性。
经典:Patran二次开发工具PCL系列教程之8

8-7
PATRAN Toolbar Icons
*ICON specifies the icon that is to be used in the Toolbar form. The icons are restricted to a 40x40 bitmap format (typically 28x28 for UNIX or 16x16 for NT). Icons can be created using various UNIX bitmap utilities or Paint for NT. A toolbar icon template (UNIX) is supplied with MSC.Patran and can be used to create user-defined icons.
The Start/End Toolbar Lines (NT only) define the boundaries of the dockable toolbars
7
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
Bottom Margin
= 0.5 in
Default Units
= Inches, Points, cm
$ Other units are Picas and mm
Print Orientation = Portrait, Landscape; Landscape $ Note use of default
•
Additional functions may be added to the toolbar
•
Patran二次开发工具PCL系列教程之9

PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
9-7
PATRAN 2.5 Results Files
There are three formats of PATRAN 2.5 results files that can be imported into MSC.Patran • • • Element Results File (.els) Nodal Results File (.nod) Displacement Results File (.dis)
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
9-5
Results Retrieval
Main way to access results in PCL is with res_utl_extract_[type]_results res_utl_extract_nodal_results() requires an integer array of 5 values to define the desired results: • Loadcase ID – res_utl_get_loadcases() • Subcase ID – res_utl_get_subcases() • Primary Result Case ID – res_utl_get_result_ids() • Secondary Result Case ID – res_utl_get_result_ids() • Layer ID – res_utl_get_layers()
patran使用技巧

分享patran使用中的一些技巧patran技巧[分享]为何我的FEM选单中不会出现Hybrid Mesh<Patran> 为何我的FEM选单中不会出现Hybrid Mesh?-->请在系统的环境变数中增加以下变数:PATRAN_USE_HYBRID_SURFACE_MESHER值设定为TRUE ,这样在surface mesh处, 除了Iso Mesh跟Paver Mesh外,就会看到另外一个Hybrid Mesh的选项[分享]MSC多解析任务批处理的方法如果仅有一台机器可以进行解析运算,有时候任务比较多的时候会时间来不及.提交模型让机器计算之后只能在旁边傻看着,什么也做不了. 其实有一种比较好一点的方法.可以用批处理文件让机器连续自动处理,下班时运行披处理文件,第二天早上来看结果.方法如下:比如有3个模型,S1.MOD,S2.MOD,S3.MOD1. 分别将上诉3个模型导出为DAT文件2.建立批处理c:\mscvn4w2002\solver\bin\nastran S1.datc:\mscvn4w2002\solver\bin\nastran S2.datc:\mscvn4w2002\solver\bin\nastran S3.dat3. 双击4. 下班5. 上班6. 导入解析结果.[转帖]PATRAN的一些小技巧1、在Patran里如何Move 一组Points 的位置, 而不改变这组Points 的ID 编号? Group/Transform/Translate的功能,这样不但编号不会变, 连property跟边界条件都会保留2、Patran如何执行多次Undo?所有Patran的操作步骤, 都记录在最新的一个patran.ses.xx中,如果需要多次undo, 可以刪除最后不需要的步骤指令行,再利用File -> Session -> Play 的方式, 执行改过的patran.ses.xx ,这样可以无限制的undo。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Output:
<Return Value> widget Item widget ID. NULL if item not created.
Comments:
Menus, menubars, and switches use itemicon widgets. The functional attributes of the item are defined by the parent widget type. The position of the item relative to other currently existing children for the parent widget is specified by the order in which the items are PAT304 Course Notes – Release 9.5 created, i.e., the item created first will appear first in the parent widget, the last item Copyright 2001 MSC.Software Corporation 7-9 created will appear last.
7-8
Item Icon
ui_itemicon_create( parent, name, iconname, toggleable )
Function:
Creates an icon item widget to be used as a child of a menu, or switch widget.
Creates a toggleicon widget.
Input:
widget parent Parent widget ID. Must be a frame, a form, or a modalform. string callback Name of PCL function called for an event in this widget. The function must be in the class in which the widget is created. Use "" if events for this widget are not of interest. numeric numeric string toggle. x y X location of toggle in inches relative to the parent. Y location of toggle in inches relative to the parent. icon Name of the icon to display describing the
Use a bitmap utility program supplied by all Workstation Vendors. Usually called bitmap (Sun, SGI). Syntax:
• • • •
% bitmap [-options ...] filename [WIDTHxHEIGHT] Example: % bitmap -size 16x16 happy_face.icon (a 16 pixel by 16 pixel file named happy_face.icon)
7-1
Icons
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
7-2
Icon Example:
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
File Widget
(UNIX example) How many PCL widgets do ห้องสมุดไป่ตู้ou see here?
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
7-10
ui_file_create
7-11
ui_file_create (cont.)
Comments:
The PCL callback function will be called when the OK button or the Cancel button is selected. Selecting the OK button instructs the UIMS to pass two arguments; the complete pathname of the selected file and "OPEN." Selecting the Cancel button instructs the UIMS to pass two arguments; the first is not used and will be set to "", and "CANCEL."
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
7-5
Creating an icon (UNIX) (cont.)
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
Output:
<Return Value> created. widget Toggleicon widget ID. NULL if toggleicon widget is not
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
7-3
Types of Icon Widgets:
Buttonicon
Itemicon
Labelicon
Toggleicon
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
7-4
Creating an icon (UNIX)
Output:
<Return Value> widget Widget id. NULL if the widget could not be created.
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
Lecture 7 Advanced Patran GUI Programming: Icons, File Widget, Spreadsheet Widget
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
Function:
Creates a file selection widget.
Input:
widget parent string numericx numericy numericwidth integernum_rows string string string string string string string string string Parent widget id. Must be a frame, a form or a modal form. callback Name of the PCL function that is called for an event in this widget. he function must be in the class in which the widget is created. Use "" if events for this widget are not of interest. X location of the widget in inches relative to the parent. Y location of the widget in inches relative to the parent. Width of the file widget, in inches. Number of items to display in the files and directory listboxes. filter_label Label describing the filter databox. filter_mask Used to specify which files appear in the listbox. dirs_label Label to appear above the listbox containing the directories. files_label Label to appear above the listbox containing the files relevant to the filter_mask. selection_label Label describing the selection databox. selection Filename to appear in the databox labeled selection_label. Also highlights in listbox, if present. ok_label Label describing the OK button. filter_label Label describing the Filter button. cancel_label Label describing the Cancel button.