Patran二次开发工具PCL系列教程之8
基于MSC_Patran界面的PCL二次开发
《现代电子技术》2010 年第 16 期总第 327 期
计算机应用技术
基于 MSC. Patran 界面的 PCL 二次开发
张军彦 , 李昌华 , 李晓辉
(西安建筑科技大学 信息与控制工程学院 , 陕西 西安 710055)
摘 要 :在对 MSC. Pat ran 进行二次开发时 ,通常需要编写自定义的图形界面 ,以实现开发者所需的一些特殊功能 。由 于 Pat ran 软件读取部分格式文件功能比较繁琐 ,要通过手动输入一些参数才能进行数据的读入 。针对这些不足 ,特进行 Pat ran 界面的二次开发 ,使得预先设置好的参数 ,通过界面函数与系统调用 ,可以直接进行数据读取 ,大大提高了效率 。最 后给出开发后的界面实例进行验证 。
Keywords : MSC Pat ran ; PCL redevelop ment ; user interface ; read data
0 引 言
随着造船技术的发展 ,船舶建造向大型化和经济化 方向发展 。MSC. Pat ran 是 MSC 公司开发的大型有限 元通用软件 ,广泛地应用于航空 、航天 、船舶 、建筑 、桥梁 等行业的工程设 、工程分析中 。Pat ran 可以用来对 建筑物进行各种分析 ,例如 :混凝土实体结构有限元分 析以及超高层建筑物的气压波动分析等 。MSC. Pat ran 具有齐全的前 、后处理功能 ,以 MSC. Pant ran 为平台 , 应用 PCL 语言并结合会话文件对 MSC. Pat ran 进行 二次开发 ,实现结构建模与分析的参数化 。PCL ( Pat2 ran Co mmand Language) 是一个高级 、模块化结构编程 语言和用户自定义工具 ,类似于 C 语言和 Fort ran 语 言 ,可用于生成应用程序或特定的用户界面 ,显示自定 义图形 、读写 Pat ran 数据库 ,建立新的功能或增强功 能 。同时通过 PCL 的二次开发 ,其他商品化的或自编 分析程序可被集成到 Pat ran 中 。
Patran基础教程08_场
(*)
60 50 40 30 20 10 0 0
-----
xy1
1
2
3
● 可以输入Excel的电子表格或者把Patran中的列
PAT301, Section 8, September 2010 Copyright 2010 MSC.Software Corporation
表输出成 Excel的电子表格 S8-10
等等一些教育学习办公写作商业经营实用性极强的文档您若觉得对您日常学习商业经营社交沟通办公写作有所帮助的话就关注我吧
第 8 部分 场
PAT301, Section 8, September 2010 Copyright 2010 MSC.Software Corporation
S8-1
FIELDS
S8-18
显示场数据
● Fields 可以 X-Y 图
表显示 ● 必须选择一个自变 量
LEGEND
model
120
100
80
60
40
20
PAT301, Section 8, September 2010 Copyright 2010 MSC.Software Corporation
0
S8-19
0
0.6
T) Thickness = 0.2 + 0.4*SINR(’
T=1.57 T Z R T=0 0.2
S8-6
PAT301, Section 8, September 2010 Copyright 2010 MSC.Software Corporation
空间场, PCL 函数输入
● PCL 表达式最多可用 3 个空间变量来定义
用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 #删除函数定义。
patran建模步骤 -回复
patran建模步骤-回复Patran建模步骤Patran是一款常用的有限元前后处理软件,用于建立有限元模型、进行前处理工作、对有限元计算结果进行后处理分析。
在进行Patran建模过程中,一般可以分为以下几个步骤。
步骤一:准备工作在进行Patran建模之前,需要准备相关的几何模型和材料数据。
对于复杂的几何模型,可以使用CAD软件绘制,并导入到Patran中;对于简单的几何模型,也可以在Patran中直接建立几何模型。
此外,还需要准备材料的物理性质数据,例如弹性模量、泊松比等。
步骤二:创建几何模型在Patran中创建几何模型的方法有多种,可以通过导入CAD文件、绘制几何形状等方式来实现。
如果是导入CAD文件,可以选择几何模型文件的格式(例如IGES、STEP等),然后按照相关提示导入CAD文件。
如果是在Patran中直接绘制几何模型,可以使用构建几何体的命令(例如点、线、平面、体等)来创建几何形状,并按照设计要求对几何模型进行编辑和变形。
步骤三:创建网格模型在Patran中创建网格模型是进行有限元分析的关键步骤。
网格模型的生成可以通过网格剖分来实现,可以选择不同的网格剖分算法和参数,以获得满足分析要求的网格模型。
在Patran中,可以使用自动剖分命令,也可以使用手动剖分命令来创建网格模型。
自动剖分命令一般适用于简单几何形状,而手动剖分命令适用于复杂几何形状。
在进行网格剖分时,还需要设置网格尺寸、单元类型、局部剖分等参数。
步骤四:定义边界条件在进行有限元分析之前,需要定义边界条件。
边界条件包括加载边界条件和约束边界条件。
加载边界条件是指施加在模型上的外部荷载,例如力、压力、温度等。
约束边界条件是指模型的约束条件,例如支撑、固定、禁止位移等。
在Patran中,可以通过加载定义命令和约束定义命令来分别定义加载边界条件和约束边界条件。
例如,可以选择加载的单元或节点,然后定义加载类型和大小;对于约束条件,可以选择需要约束的节点或边等,然后定义约束类型和大小。
精典材料Patran的PCL用户手册V20
MSC.Patran PCL HandbookIn a Nutshell (7)What is PCL? (7)What can PCL be used for? (8)How does PCL work? (9)All you really need to know is on this page! (10)Documentation (10)PCL for Everyone (11)Entering Equations (11)Entering Data (12)Session Files (13)Rebuilding Models (14)PCL for the More Adventurous (17)Parametric Modeling (17)Adding a Graphical User Interface, GUI (21)Exercise 1: Session Files (22)PCL Programming Basics (24)Overview (24)PCL Expressions (26)Expressions, Comments, Syntax Tips (26)Identifiers (28)Naming Conventions (28)Variable / Function Scope (29)Structure of a PCL Function (30)Function Basics (30)Simple PCL function Example (31)Exercise 2: Hello World! (33)Exercise 3: Effective PCL (34)PCL Operators (35)String comparisons (35)PCL Variables and Constants (36)Datatypes (36)Variable Scope (37)Directly Allocated Arrays (38)Virtual arrays (39)Virtual strings (41)Loop Control Statements (42)For Loop (42)While Loop (42)Repeat Loop (43)BREAK (44)CONTINUE (45)Exercise 4: Writing Files (46)Exercise 5: Reading Files (48)Conditional Control Statements (49)IF Statement (49)SWITCH Statement (50)Structure of a PCL Function (51)Compiling and Linking PCL Functions (54)Primary PCL Directives (55)Compiling PCL outside of MSC.Patran (59)Linking Compiled Libraries (60)Other PCL Directives (61)Start Up Files (62)Exercise 6: p3epilog.pcl (63)Debugging (64)Debugging Compile Errors (64)Debugging Runtime Errors (65)Accessing PCL Functions (67)From The Command Line (67)From Any MSC.Patran Form (68)PCL Functions with Field Variables (69)MSC.Patran Built-In Functions (70)Naming Conventions for Applications (71)Naming Conventions for Other Operations (72)Exercise 7: Group Elements By Shape (74)Graphical User Interface (75)The PCL Class Statement (76)PCL Widgets (77)Required Functions for Building/Displaying a Form (78)The init() Function (78)The display() Function (79)Widget Callbacks (82)What Are They? (82)What Are They Used For? (83)Callback Arguments (Widget Function Data) (83)Widget Placement (85)Widget Variables (87)Modifying Widgets (88)Getting Data from Widgets (89)Putting it all Together (Example) (90)Exercise 8: Simple Form (92)The C-Preprocessor and Include Files (93)Make Files (94)Exercise 9: Callbacks (96)Handling Errors and Messaging (98)Errors from Built-In Functions (98)Custom Error Messages (99)Using User Messages Database (99)Without a Messages Database (100)Taking Advantage of the UNDO Feature (102)Select Mechanism (103)Select Mechanism GUI Mechanics (103)Select Databoxes, Select Frames, and Select Menus (103)GUI PCL Example (105)List Processor (106)List Processor Mechanics (106)All You Really Need to Know (107)Exercise 10: Form to Group Elms By Shape (110)Executing Programs Outside of MSC.Patran (112)Spawning Remote Processes (112)Locking a database (114)Using C and Fortran executables to access a MSC.Patran database directly. (115)External Access of an MSC.Patran Database (116)Special Widgets (118)File Widget (118)Spreadsheet Widget (121)Exercise 11: File Widget (122)Adding Help/Description to your PCL (123)Percent Complete (124)Functions (124)Example (124)Event Manager (125)General (125)Functions (126)Example (126)Primitive Graphics (127)Graphic Objects (127)Graphic Segments (128)Example (129)Another Example (130)Exercise 12: Primitive Graphics (131)MSC.Patran Customization (132)Adding Utility Programs to the Main Menu (132)Example (133)Example: p3_user_menu.my_menu.def (134)Customizing the MSC.Patran Toolbar (135)Exercise 13: Pulldown Menu (138)Exercise 14: Toolbar (139)Some Final Thoughts (141)Appendix A (144)Built-in Function Examples (144)Documentation for a typical MSC.Patran built-in function. (145)To get all the nodes and their global coordinates (146)To get the topology of every element (147)To get the shape of every element (148)To get all the element connectivity for all elements (149)To get the elements associated to a particular element property set (150)To get an element property value (shell thickness) for a specific element (151)To get a material property value (153)To get a list of all groups (154)To get the nodes and elements associated to the current group (154)To get result values for specified elements (155)Appendix B (164)Strings & String Functions (164)Declaration (165)Initialization (165)String Comparisons (165)Functions (166)Appendix C (174)Noteworthy Functions (174)sys_mov e_raw(...) (175)mth_array_search(...). (176)mth_sort(...) . (177)mth_sort_row(...).. (178)mth_sort_column(...) . (178)fem_geom_edge_length(...) .. (179)fem_geom_face_area(...). (179)fem_geom_elem_volume(...). (179)fem_geom_elem_location(...) .. (180)Appendix D (181)Form Spacing Parameters (appforms.p) (181)* SPACING (182)Appendix E (205)MSC.Patran Architecture (205)Appendix F (207)Shareware Compiling Functions (207)Appendix G (210)Parametric Patran (210)Appendix H (216)Additional List Processor Notes (216)List Processor Mechanics (217)List Processor Functions (217)List Processor Sublist Functions (219)List Processor Attribute Functions (220)Miscellaneous List Processor Functions (220)List Processor Examples (222)Easy to Use List Processor Functions (226)Appendix I (227)Key Mapping (227)Appendix J (230)Widget Classification (230)Appendix K (233)User Defined AOM (233)In a NutshellWhat is PCL?❑PCL stands for Patran Command Language❑Comprehensive, fully functional computer programming language❑Specifically and uniquely suited for MCAE applications ❑Delivered as a part of MSC.Patran❑Versatile and easy to useWhat can PCL be used for?❑Integrate application or site-specific programs with the MSC.Patran user interface and database❑Generate parametric/variational models for design/optimization ❑Integrate commercial and/or in-house analysis codes with MSC.Patran❑Display custom graphics❑Access the MSC.Patran database❑Create new and/or enhanced MSC.Patran functionality❑Database management for analysis files❑Eliminate tedious, repetitive proceduresHow does PCL work?❑All MSC.Patran commands are first interpreted by the PCL command interpreter❑PCL expressions are interpreted by a C program❑PCL functions can be compiled into libraries (more efficient binary representation) and “linked” with a MSC.Patran session❑“Built-in” PCL functions are written in C or FORTRAN❑MSC.Patran forms and menus can be created via PCL calls to Xlib, the X-window function library❑FORTRAN and C functions can be “linked” with MSC.Patran through PCLAll you really need to know is on this page! Documentation❑PCL and Customization - General programming guide for PCL.How to build forms, compile, manage libraries, access thedatabase, read/write files, etc.❑PCL Reference – Description of functions written to the session file.❑Develop: The MSC.Patran Toolkit – Documentation of additional functions for database access, etc.PCL for Everyone Entering EquationsUse of PCL when creating spatial fields:‘X + ‘X**2 –sinr(‘X)The PCL interpreter interprets anythingimmediately following a ‘ symbo l as afield variable as opposed to a PCLfunction, such as, sinr().Entering DataUse of PCL when entering geometric coordinates: [ `5./16.` 0 0 ]The PCL interpreter “evaluates” expressions enclosed in back tics, “`”.Other examples:[ `radius/length` 0 0 ]< `cosr(theta)` 1 1 >[ `MyFunction(radius)` 0 1 ]Session FilesSession and journal files are comprised entirely of PCL commands. Model changes (dimensions, mesh density, etc.) can be made quickly by editing and then replaying the session or journal files.$# Session file patran.ses.01 started recording at 16-Aug-01 14:33:54$# Recorded by: MSC.Patran 2001STRING asm_create_patch_xy_created_ids[VIRTUAL]asm_const_patch_xyz( "1", "<10 10 0>", "[0 0 0]", "Coord 0", @asm_create_patch_xy_created_ids )$# 1 Patch created: Patch 1STRING sgm_edit_surface_add_h_edit_ids[VIRTUAL]sgm_edit_surface_add_hole( 1, 1., TRUE, "", "[5 5 0]", "", "Surface 1", @sgm_edit_surface_add_h_edit_ids )$# 1 Surface Edited: Surface 1$# Session file patran.ses.01 stopped recording at 16-Aug-01 14:34:52Rebuilding ModelsThe following session file creates a trimmed surface, 10” x10”with a 1” diameter hole at the center. Note that the parameter that controls the diameter of the hole is indicated below.$# Session file patran.ses.01 started recording at 16-Aug-01 14:33:54$# Recorded by: MSC.Patran 2001STRING asm_create_patch_xy_created_ids[VIRTUAL]asm_const_patch_xyz( "1", "<10 10 0>", "[0 0 0]", "Coord 0", @asm_create_patch_xy_created_ids )$# 1 Patch created: Patch 1STRING sgm_edit_surface_add_h_edit_ids[VIRTUAL]sgm_edit_surface_add_hole( 1, 1., TRUE, "", "[5 5 0]", "", "Surface 1", @ sgm_edit_surface_add_h_edit_ids )$# 1 Surface Edited: Surface 1$# Session file patran.ses.01 stopped recording at 16-Aug-01 14:34:52In the session file below, the previous session file is edited to change the hole diameter from 1” to 4”$# Session file patran.ses.01 started recording at 16-Aug-01 14:33:54$# Recorded by: MSC.Patran 2001STRING asm_create_patch_xy_created_ids[VIRTUAL]asm_const_patch_xyz( "1", "<10 10 0>", "[0 0 0]", "Coord 0", @asm_create_patch_xy_created_ids )$# 1 Patch created: Patch 1STRING sgm_edit_surface_add_h_edit_ids[VIRTUAL]sgm_edit_surface_add_hole( 1, 4., TRUE, "", "[5 5 0]", "", "Surface 1", @ sgm_edit_surface_add_h_edit_ids )$# 1 Surface Edited: Surface 1$# Session file patran.ses.01 stopped recording at 16-Aug-01 14:34:52Session files can be executed or “played” by selecting File/Session/Play … from the top menu.PCL for the More Adventurous Parametric Modeling❑Session files can be parameterized by defining and using variables during the MSC.Patran session❑First, variables are declared and initialized via the MSC.Patran command lineSecond, the variables are used as input into the appropriate MSC.Patran forms (note the use of ` `, back tics)Upon application, the PCL interpreter evaluates `radius` (i.e., sets it equal to 1.0 in this example) and creates the curve. Note that the variable is passed to the session file in its unevaluatedBy using variables as parameters during MSC.Patran input, it is very easy to edit and change dimensions, mesh parameters, etc. in the session file.PCL for the more Adventurous Adding a Graphical User Interface, GUIThe next step might be to create a user interface to run the plate session file!Exercise 1: Session FilesUse MSC.Patran to create a parameterized session file that createsa rectangular surface with an arbitrarily located hole.1) Create variables for the dimensions shown below.2) Steps:a) Create variables using MSC.Patran’s command lineb) Create/Surface/XYZ (use variables length and width)c) Edit/Surface/Add Hole (use x_center, y_center, and diameter) Extra credit: Include error checking, i.e., it doesn’t make sensefor the hole to be outside the surface boundary.IF (x_center + diameter/2.0 > length) THEN RETURNExtra credit: Include meshing, boundary conditions, elementproperties, etc.Extra credit: Use ui_read_real(prompt) to enter the variablevalues interactivelyExtra credit: Turn your session file into a PCL FUNCTION.Exercise 1 Below is an image showing an MSC.Patran form allowing the interactive creation of the model for this exercise.NB – See Appendix G for notes about Parametric Patran.1) Variables and macros are defined interactively via a GUI2) Variables and macros are persistent3) Plus, more. See Appendix G for the detailsPCL Programming Basics Overview❑PCL is a full-featured programming language.❑Operators for arithmetic, relational, and string expressions.Examples include:❑Variables with type, scope, and dimension attributes INTEGER i, j, status, NodeIds(1000)LOGICAL flagREAL xyz(1000, 3), pressure(100), timeGLOBAL STRING my_group[32], all_groups[32](100)❑Dynamically allocated virtual strings and arraysINTEGER node_ids(VIRTUAL)STRING groups[32](VIRTUAL), MyString[VIRTUAL]❑Intrinsic functions for math, string manipulation, etc.sinr(angle)cosd(angle)mth_abs(MyVal)mth_sort(MyArray, CompactDuplicates, NumLeft)mth_array_search(MyArray, Look4, Sorted)str_length(MyString)str_substr(MyString, Position, SubStringLength)str_index(StringToSearchIn, StringToSearchFor)str_token(MyString, Delimiter, TokenNumber, [Compress])PCL Programming Basics ❑Loop control features, such as, WHILE, FOR, REPEAT, and LIST❑Conditional control structure, such as, IF-THEN-ELSE and SWITCH-CASE❑Subroutine (procedure) and function (command) calls❑Class grouping of related functions❑Read/write access to external ASCII and/or binary filestext_open(FileName, Options, 0, 0, FileId)text_read_string(FileId, InString, InStringLength)text_write_string(FileId, OutString)text_read(FileId, Format, MyIntegers, MyReals, MyChar)text_write(FileId, Format, MyIntegers, MyReals, MyChar)text_close(FileId, Options)file_exists(FileSpec, Options)file_delete(FileSpec)❑Access to MSC.Patran “built-in” functions that allow for direct access to the MSC.Patran database, geometry creation,drawing graphic primitives,db_count_nodes(NumNodes)db_get_node_ids(NumNodes, NodeIds)asm_const_grid_xyz(output_ids, coordinates_list, coord_frame, @created_ids)PCL Expressions Expressions, Comments, Syntax Tips❑Sample PCL expressions include:theta = 360.0 – MTH_ASIND(MyAngle)IF (radius >= 20.0) THEN radius = 20.0length = str_length(MyString)build_gear_geometry(30., 56., 3)❑PCL comments begin with a “/*” and end with a “*/”/*This is a comment.Look Ma, I’m making comments in PCL!Has anyone seen or heard from Elvis lately?*/a = 2 /* set mysterious factor equal to 2 */❑Alternatively, single line comments may begin with “$”$ Don’t you just hate to comment your programs?❑More than one PCL expression can co-exist on a line using a semi-colon, “;”alpha = 30.0; beta = 120.0❑PCL expressions can be continued on subsequent lines by using the “@” symbolui_wid_set(main_form, @“HEIGHT”, @NewHeight)ui_wid_set( /* widget_id */ main_form, @/* parameter */ “HEIGHT”, @/* value */ NewHeight)PCL Expressions ❑Don’t break expressions in the middle of a keyword, constant, or identifier❑Multiple blanks are the same as a single blank space❑Lines beginning with “!” (bang operator) are echoed to the xterm (UNIX) or command window (NT), but are not executedIn MSC.Patran type: !`i` nodes createdIn the xterm you see: %27 nodes created❑PCL expressions beginning with “>” are echoed to the session file❑PCL expressions can be typed directly into MSC.Patran at the command line❑PCL expressions may also be created with an editor in a text file and directed into MSC.Patran as a session file or by using the PCL directive !!INPUTIdentifiersNaming Conventions❑Function names and/or variable names are called identifiers ❑Can be up to 32 characters long❑Must begin with a non-digit❑Case insensitive (as is all of PCL)❑Cannot be a reserved keyword, i.e., FOR, IF, etc.❑Valid identifierscurrent_groupCurrentGroupMyString❑Invalid identifiersa_very_very_very_very_very_very_very_very_long_name 95abclistIdentifiers Variable / Function Scope❑Global variable names and functions share the same name space❑When two function names or two variable names conflict, the most recent addition supercedes the previous❑When function names and variable names conflict, the variable name takes precedence❑When compiling functions, PCL will indicate if a function name is superceded by writing “Cleared memory function” to thehistory window❑Hint: Use a unique prefix to keep function definitions separate,i.e au_do_this_and_that.pclStructure of a PCL Function Function Basics❑PCL functions begin with a FUNCTION statement and end with an END FUNCTION statement.❑The FUNCTION statement may contain an argument list to be passed in or out of the function.❑An optional RETURN statement can be used to return a calculated value from the function to the calling statement.❑Processing of the function terminates at either the END FUNCTION statement or a RETURN statement.❑There may be multiple RETURN statements within a single function.Simple PCL function Exampleanother_simple_function(29)$#My favorite number is 29$#My least favorite number is 13Sample output. The ui_write functions writetext to the history window, the session file(patran.ses.##), and the journal file(model.db.jou)Exercise 2: Hello World!Write and execute a PCL function that accepts a single real number argument and echoesHello World, my favorite number is ….to the MSC.Patran session file and history window.Your function will use either the ui_write(…),ui_writef(…), or ui_writec(…) functions.If you use the ui_writef(…) and ui_writec(…) functions, refer to the documentation for the correct format specifiers.Extra credit: How would this function change if you wanted to echo your favorite 10 numbers to the session file? Extra credit: How would this function change if you wanted to echo your favorite color to the session file?Exercise 3: Effective PCLWrite an essay on how the effective use of PCL could:a) Help create a lasting world peaceb) Eliminate world hungerc) Conquer the common coldd) Stop global warmingExtra credit: How could PCL be used to find Elvis?PCL OperatorsExamplesDist = mth_sqrt((x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2) MyString3 = MyString2//”hijk”IF (a == b) THEN c = dIF (a == b && a == c) THEN ui_write(“Equilibrium”)x += 1 (this is equivalent to x = x +1)String comparisons❑The string comparison operators are special in that they ignore trailing blanks and uppercase and lowercase. Therefore, all of the following expressions are TRUE“ABC” == “ABC ““ABC” == “abc”❑Leading blanks are compared, i.e., “TEST” != “ TEST”❑To perform case sensitive comparisons use the str_equal() function, i.e.,IF (str_equal(GroupName1, GroupName2)) THEN RETURN 0PCL Variables and Constants Datatypes❑LOGICAL Boolean value: TRUE or FALSELOGICAL done, created31-1)❑INTEGER Value between +/- (2INTEGER i, num_nodes, node_id❑REAL Single precision floating value between 1.0E-30 and1.0E+30 (positive or negative)REAL x, y, z, force, pressure❑STRING Character string surrounded by double quotes, “Have you seen Elvis?”. Size or string length is defined with brackets, [ ]STRING FileName[80], GroupName[32]❑WIDGET Value is assigned by calls toUI_WIDGET_NAME_CREATE(…), used to create andmanipulate forms, etc.WIDGET main_form, MyButton, group_lboxVariable Scope❑GLOBAL Available to all functions during the MSC.Patransession❑LOCAL Default, only visible within the defining function ❑STATIC Same as LOCAL, but retains its value betweencalls❑CLASSWIDE Available to all functions in the CLASS andretains its value during the MSC.Patran sessionDirectly Allocated Arrays❑Directly allocated arrays can have any number of subscripts (dimensions), defined within parentheses ()❑Assigned upper and lower bounds, ArrayName(Lower:Upper)INTEGER MyArray(2:10)❑ Default lower bound is 1 (not 0) ❑ Available for all datatypes❑Row major (unlike Fortran which is column major)INTEGER MyArray(2, 3) = 1, 2, 3, 4, 5, 6❑Array dimensions are inherited from the argument list, i.e., PCL passes by reference❑Declaration ExamplesREAL displacements(6, 200) STRING group_names[32](20) INTEGER ids(0:2, 0:4, 0:10) LOGICAL exists(12)Virtual arrays❑Any variable can be defined as a VIRTUAL array instead of a directly allocated array. Virtual arrays do not have storagelocations assigned to them at program initialization. The size and amount of storage is allocated as requested and can bereused for other virtual arrays.❑To declare a virtual array, use the keyword VIRTUAL in place of the subscripts for the declaration, i.e.,REAL MyVals(VIRTUAL)INTEGER NodeIds(VIRTUAL)❑Storage is allocated using the function, sys_allocate_array(), or sys_allocate_array(MyVals, 1, 300)sys_allocate_array(MyVals, 1, 300, 1, 3)sys_allocate_array(MyVals, 1, 300, 1, 3, 0, 5)etc.❑Storage may be reallocated using the function,sys_reallocate_array(),sys_reallocate_array(MyVals, 1, 300, 1, 3)❑Storage may be freed using the function, sys_free_array(), sys_free_array(MyVals)Virtual array examplePCL Variables and Constants Virtual strings❑Any string variable can be defined as a VIRTUAL length string instead of a fixed length string. Virtual length strings do nothave storage locations assigned to them at programinitialization. The string length is allocated as requested and can be reused.❑To declare a virtual length string, use the keyword in place of the subscripts for the declaration, i.e.,STRING picklist[VIRTUAL]❑The string length is allocated using the sys_allocate_string() functionsys_allocate_string(picklist, 1000)❑The string length may be modified using thesys_reallocate_string() functionsys_reallocate_string(picklist, 2000)❑The string storage may be freed using the sys_free_string() functionsys_free_string(picklist)❑ A virtual length string can also be a virtual array, i.e., STRING picklists[VIRTUAL](VIRTUAL)Loop Control StatementsFor Loop❑SyntaxFOR (var=numeric_expr TO numeric_exprnumeric_expr label statements … END FOR❑ExampleAvgTemp = 0.0FOR (i = 1 TO NumNodes) AvgTemp += NodalTemp(i) END FORAvgTemp = AvgTemp/NumNodesWhile Loop❑SyntaxWHILE (logical_expression ) [label ] statements … END WHILE❑ExampleAvgTemp = 0.0 i = 1WHILE (i <= NumNodes)AvgTemp += NodalTemp(i) i += 1 END WHILEAvgTemp = AvgTemp/NumNodesRepeat LoopThis is similar to a WHILE Loop except that it will always be executed at least once. Only use REPEAT loops if you want to ALWAYS execute the loop at least once, otherwise us a WHILE loop.❑SyntaxREPEAT [label]statements …UNTIL (logical_expression)❑ExampleAvgTemp = 0.0i = 1REPEATAvgTemp += NodalTemp(i)i += 1UNTIL (i > NumNodes)AvgTemp = AvgTemp/NumNodesBREAKThe BREAK statement is used to exit a loop prior to its normal termination. It can be used in any of the loop statements.BREAK [❑END WHILE…❑Example 2 (nested loops, using labels)WHILE (i <= NumNodes) MainLoopWHILE (j <= 100) AnotherLoopWHILE (k <= 200) InnerLoopIF (status != 0) THEN BREAK MainLoopIF (status != 0) THEN BREAK AnotherLoopIF (status != 0) THEN BREAKIF (status != 0) THEN BREAK InnerLoopEND WHILEEND WHILEEND WHILECONTINUEThe CONTINUE statement is used to skip to the end of the loop ❑SyntaxCONTINUE [label]❑Example 1 (reading a text file)INTEGER file_id, lengthSTRING read_str[80]/* read grid information */WHILE (text_read_string(file_id, read_str, length) == 0)END WHILE❑Example 2 (nested loop, using labels)WHILE (i <= NumNodes) MainLoopREPEAT InnerLoopCONTINUE MainLoopBREAK InnerLoopCONTINUECONTINUE InnerLoopUNTIL (j > 1000)END WHILEstatements …Exercise 4: Writing FilesCreate a PCL function to write nodal data to a user-defined file. 1) The function should have a single argument, the filename to becreated, i.e., FUNCTION write_nodes_to_file(FileName)2) The data should be written to the file as a table, i.e.,Node Id x-coordinate y-coordinate z-coordinate3) Use virtual arrays4) Use the following built-in functions:db_count_nodes(NumNodes)db_get_node_ids(NumNodes, NodeIds)db_get_nodes(NumNodes, NodeIds, rcids, acids, NodeXYZ)text_open(FileName, Options, idum, idum, FileId)text_close(FileId, Options)text_write(FileId, Format, Ints, Reals, Chars)text_write_string(FileId, OutString)5) Use the documentation if you have questions about thearguments to the built-in functions.6) Think about your choice for the format argument in thetext_write(…) function. Will your file be comma or spacedelimited? Will it be fixed or free format?7) Sample code outline:a) Declare variablesb) Count nodes in the databasec) Allocate arraysd) Get node Idse) Get node coordinatesf) Open fileg) Write data to the file with a looph) Close filei) Be sure to include a message that the file output is completeWriting Files Extra credit: Include a header line at the top of the file thatincludes the filename and the total number of nodeswritten to the file.Exercise 5: Reading FilesWrite a function to read the file created in Exercise 4.1) The function should accept a single argument, i.e., the filenameto be read.FUNCTION ReadFile(FileName)2) Use the data in the file to create nodes with the following built-in function from the PCL Reference Manual:fem_create_nodes_1(RefCIDList, AnalysisCIDList, GeomFlag, @NodeIDList, XYZList, NodesCreatedList)3) Use the following built-in functions:text_open(FileName, Options, idum, idum, FileId)text_close(FileId, Options)text_read(FileId, Format, Ints, Reals, Chars)4) Sample code outline:a) Declare variablesb) Open the filec) Read the file within a loopd) Create new nodes as the file is read within the loope) Close the fileExtra credit: What if a node ID to be created already exists in the database?Extra credit: What if the file to be read doesn’t exist? Whatfunction can be used to determine if a file exists? Extra credit: Searching the documentation reveals anotherfunction that can be used to create nodes, i.e.,db_create_nodes(num_nodes, rcids, acids, xyz, group_id,node_ids, node_exists). Why might you use thisfunction versus fem_create_nodes_1(…)?Conditional Control Statements IF Statement❑SyntaxIF (logical_expression) THENstatements …ELSE IF (logical_expression) THENstatements …ELSEstatements …END IF❑ExampleIF (MyKeyWord == “CBAR” || MyKeyWord == “CBEAM”) THEN statements …ELSE IF (MyKeyWord == “CTRIA” || MyKeyWord == “CQUAD”) THEN statements …ELSE IF (MyKeyWord == “GRID”) THENstatements …ELSEstatements …END IF。
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二次开发语言
3. PCL函数库 函数库 4. PCL编译和连接 编译和连接
方式: 命令行; 方式 1)Patran命令行;2) p3cplcomp; 3)make 命令行 Patran命令行和 p3pclcomp方式 命令行和 方式 !!input <filename>.pcl 编译、连接 编译、连接filename.pcl,并将函数调入 ,并将函数调入Patran 直接运行文件中的函数 !!Compile <filename>. pcl !!Library xxx.plb Make 创建完程序后,键入 自动编译并存入库中, 创建完程序后,键入Make, Patran自动编译并存入库中,但第一次 自动编译并存入库中 用make须给出 须给出Makefile 文件 须给出 编译filename.pcl,并将其存入xxx.plb中 ,并将其存入 编译 中 将库调入Patran, 调入后可执行该函数 将库调入
PCL功能 功能
用小程序, ◆编制Patran用小程序,扩展 编制 用小程序 扩展Patran功能 功能 ◆把自己的分析程序集成到Patran统一环境中,用Patran做前后处理,象NASTRAN, 把自己的分析程序集成到 统一环境中, 做前后处理, , 统一环境中 做前后处理 ABAQUS,DYNA3D一样 , 一样 的模型作参数化研究, ◆对Patran的模型作参数化研究,针对特殊工程问题,建立统一参数化模型 的模型作参数化研究 针对特殊工程问题, ◆方便地编制“傻瓜”界面,供设计工程师和新手使用 方便地编制“傻瓜”界面,
patran技巧
Patran使用技巧display---color palette点白色的小图标把lightness 设置为1点黑色的小图标把lightness 设置为0背景颜色就是白色的了!Nastran计算后,用Pastran调用结果文件时发现,计算的结果文件默认放在了C:/temp文件夹,怎样修改结果文件的路径阿,请各位指教!patran临时文件目录的修改:在桌面的patran图标上右击选属性,打开后修改起始位置即可。
patran调用nastran计算时临时文件目录的修改:在桌面的我的电脑图标上右击选属性,打开后选择高级页面,选环境变量,进去后修改用户环境变量temp和tmp即可。
P3_TRANS更改这个文件里面的路径就直接可以无缝连接了在patran的安装文件夹里面patran和nastran这样修改文件的存放路径还是可以的,如果是其他的,如fatigue,在这样修改就会引起错误,所以建议大家还是不要改好了啊,呵呵1Q:<Patran> 为何我的FEM选单中不会出现Hybrid Mesh?请在系统的环境变数中增加以下变数:PATRAN_USE_HYBRID_SURFACE_MESHER值设定为 TRUE , 这样在surface mesh处, 除了Iso Mesh跟Paver Mesh外,就会看到另外一个Hybrid Mesh的选项.科研中国整理.2Q:MSC多解析任务批处理的方法A:如果仅有一台机器可以进行解析运算,有时候任务比较多的时候会时间来不及.提交模型让机器计算之后只能在旁边傻看着,什么也做不了. 其实有一种比较好一点的方法.可以用批处理文件让机器连续自动处理,下班时运行披处理文件,第二天早上来看结果.方法如下:比如有 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. 导入解析结果.3Q:在 Patran里如何Move 一组Points 的位置 , 而不改变这组 Points 的 ID 编号?A:Group/Transform/Translate的功能, 这样不但编号不会变, 连property跟边界条件都会保留.4QPatran如何执行多次Undo?A:所有Patran的操作步骤, 都记录在最新的一个patran.ses.xx中,如果需要多次undo, 可以刪除最后不需要的步骤指令行, 再利用 File -> Session -> Play 的方式, 执行改过的patran.ses.xx ,这样可以无限制的undo。
Patran二次开发工具PCL系列教程之
parent
ID of the parent widget. Must be a menu, menubar, or a switch.
Name of the widget. This name is frequently used as an argument for the callback function for the item's parent.
Lecture 7 Advanced Patran GUI Programming: Icons, File Widget, Spreadsheet Widget
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)
Toggleicon widget ID. NULL if toggleicon widget is not created.
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
7-8
Item Icon
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
PCL入门教程
PCL 实例03 – form
exam03.pcl
启动Patran,在patran的命令行中输入
!!input “path\exam03.pcl” 然后就可以在Patran中调用exam_form.init(),初始化form。 调用exam_form.display(),显示form
PCL 实例04 – 在菜单中调用form
7定义了一个三维数组通过table515引用数组中的第一个数realdatavirtual定义可变数组stringlinevirtual定义可变字符串stringstr30vurtual定长度字符串数组pcl变量有效作用范围global全局变量local局部变量static函数中使用时不能改变其值classwide整个类里面有效例如
PCL 培训
PCL简介 Patran Command Language
PCL 是一种计算机编程语言,安装 Patran 时, PCL 语言软件开发环境一起 安装,与C语言语法类似。
PCL功能简介 1. 生成可以直接被Patran调用的函数,扩 展Patran的功能。 2. 在Patran中,生成用户界面和界面元素, 响应界面事件。 3. 调用Patran的内部函数。 4. 调用外部可执行程序(例如Nastran)。
PCL变量
数据类型
整数 INTEGER a, b, c 实数 REAL x, y, z 字符串 STRING name[20], option[130] 逻辑变量 LOGICAL flag =(TRUE or FALSE) 用户界面元素 WIDGET box, button
PCL变量
PCL 函数
FUNCTION fname (arglist ) declarations... statements...
patran培训教材(有限元分析)
目录第一章 Patran基础知识 (2)第二章悬臂梁的有限元建模与变形分析 (12)第三章受热载荷作用的薄板的有限元建模与温度场求解 (20)第四章带孔平板的受力分析(平面) (23)第五章厚壁圆筒的受内压作用时的应力分析 (27)第六章受压力载荷作用时板的受力分析 (31)第七章板的模态分析 (34)第八章板的瞬态响应分析 (37)第九章板的频率响应分析 (40)第十章提取车架中性面的模态分析 (43)第一章 Patran 基础知识一.Patran 的用户界面介绍Patran 具有良好的用户界面,清晰、简单、易于使用且方便记忆,其用户界面如图1-1所示。
图1-1 patran 界面按照各部分的功能,可将Patran 界面划分为四个区域:菜单和工具栏区、操作面板区、图形编辑区、信息显示和命令行输入区。
下面,就分别对这几个区域进行介绍。
1.菜单和工具栏区如图1-2所示,patran 的界面上有一行菜单,两行工具栏。
图1-2 菜单工具栏Patran 的菜单是该软件的重要组成部分,使用菜单项,可以完成多设置和操作。
本来,菜单与各种工具是配合使用的,两者是不能独立区分的。
这里对菜单栏进行简单的介绍,一般情况下,Patran 有九个主菜单项,如图1-2所示,文件菜单栏应用菜单按钮工具栏管理(File)菜单主要用于Patran数据库文件的打开/关闭,同时也用来从其他CAD系统输入模型;组(Group)菜单主要用于组的操作,作用类似CAD系统中的“层”;视窗管理(Viewport)菜单用于视窗设置;视图操作(Viewing)菜单用于图形显示设置,包括了工具栏中一些工具的功能;元素显示管理(Display)菜单用于设置各种元素的显示方式;参数设置(Preferences)菜单用于选择求解器,定制用户自己的环境等操作;工具选项(Tools)菜单中提供了许多非常有用的工具;在线帮助(Help)菜单为使用者提供在线帮助。
patran工作顺序介绍
▲ ▲常用Motif工具
Select Databox 数据选择框 Toggle button 二相开关 Push button 按钮 Data Selection 数据选择 Slide bar 滚动杆 Pull down or option menu 下拉菜单
4. 数据输入
▲鼠标屏幕上拾取
▲ ▲ Select Menu Select Menu 是选择过滤器 当点某Select databox数据输入区后, 相应Select Menu会自动弹出 如选点,弹出Point Select Menu , 选线,弹出Curve Select Menu, 选面,弹出 Surface Select Menu 选体,弹出 Solid Select Menu等
评价结果
▲ ▲直接在Patran中建立 ▲ ▲读入CAD软件输出模型
CAD软件接口:CATIA,Pro/Engineer,CADDS5,Euclid,UG,AutoCAD,SolidWorks,SolidEdge 数据交换格式:IGES, STEP203, STEP209 相同CAD软件建模核心:Parasolid, ACIS
典型点选择菜单
如:real radius radius=5.0 [‘radius ‘,0. 0.0]
任何点 几何点 结点 二线交点 线上一点 面上顶点 点面交点 面上任意拾取一点 输入点坐标或在屏幕上任意点
5. PATRAN有关的文件
名称 Modelname.db Madelme.db.bkup Patran.ses.number Modelname.db.jou Settings.pcl p3epilog.pcl
▲ 强大的布尔计算、实体建模、抽取中面、几何编辑功能 ▲ 强有力的网格生成功能 ▲ 逼真的结果可视化功能 ▲ 开放的软件开发环境
经典:Patran二次开发工具PCL系列教程之8
8-1
2
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
8-2
Display - Toolbar
The Toolbar provides quick access to frequently used functions
There is also an option for whether or not to load the icon into the toolbar when PATRAN is executed.
– In order for the icon to load into MSC.Patran,
– *LOAD ITEM must be added after the *HELP call.
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
• i.e., top to bottom in the file refers to the icons left to right on the toolbar p3toolbar.def file example:
Start Toolbar = Transform *ICON= tbrotatexy.bmp *CLASS= uil_toolbar *FUNCTION= rotate_xy *HELP= Mouse Rotate XY *LOAD ITEM
Patran二次开发工具PCL系列教程之8
= Postscript Default
Print Orientation = Portrait, Landscape; Landscape $ Note use of default
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
The Start/End Toolbar Lines (NT only) define the boundaries of the dockable toolbars
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
$
= 100 %
Image Size = Fit on Page, As Is Scale Factor = No Show; 1.0 Center = No Show; Yes Draw Borders $ Note use of “No Show” and a default
= Yes, No
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. • tbblank.28.icon
基于MSC.Patran界面的PCL二次开发
基于MSC.Patran界面的PCL二次开发
张军彦;李昌华;李晓辉
【期刊名称】《现代电子技术》
【年(卷),期】2010(033)016
【摘要】在对MSC.Patran进行二次开发时,通常需要编写自定义的图形界面,以实现开发者所需的一些特殊功能.由于Patran软件读取部分格式文件功能比较繁琐,要通过手动输入一些参数才能进行数据的读入.针对这些不足,特进行Patran界面的二次开发,使得预先设置好的参数,通过界面函数与系统调用,可以直接进行数据读取,大大提高了效率.最后给出开发后的界面实例进行验证.
【总页数】4页(P17-19,22)
【作者】张军彦;李昌华;李晓辉
【作者单位】西安建筑科技大学信息与控制工程学院,陕西,西安,710055;西安建筑科技大学信息与控制工程学院,陕西,西安,710055;西安建筑科技大学信息与控制工程学院,陕西,西安,710055
【正文语种】中文
【中图分类】TN911-33
【相关文献】
1.裂纹分析有限元重合网格法及基于MSC.Patran的二次开发 [J], 张允涛;黄其青;殷之平;谢伟
2.用MSC.Patran的PCL二次开发用户界面 [J], 唐友宏;陈宾康
3.一个基于MSC.Patran二次开发的车桥CAE软件 [J], 周明刚;陈源;丁律辉
4.基于MSC.Patran的水下航行器噪声专用程序二次开发 [J], 单威俊;冷文浩;蒲海;金建海
5.基于MSC.Patran的螺栓模拟功能的二次开发与应用 [J], 姜子刚;刘世谦;张金梅;于硕;韩小坤;刘钊宾;邢首辰
因版权原因,仅展示原文概要,查看原文内容请购买。
Patran操作界面定制工具栏功能
Patran中提供强大的定制工具栏功能,创建定制工具栏将减少筛选菜单和点击鼠标次数。
使用patran的命令语言(PATRAN COMMAND LANGUAGE)代码写入会话文件从而实现记录用户工作会话,所以在工具栏操作就能很方便地捕捉和重用这些操作步骤。
以下使用例子演示创建一个工具栏用于自动创建四面体四节点网格。
实现方法分以下5个步骤:1.记录Patran宏命令语言。
2.生成PCL文件3.创建定制图标4.修改工具栏定义文件5.设置Patran调用PCL函数文件以下使用四面体四节点网格划分的例子进行详细描述具体步骤:1. 记录Patran宏命令语言。
在patran中的宏命令语言通常存储在工作路径下的patran.ses.#文件中。
对patran宏命令语言较为熟悉的人员可以直接在该目录中取出针对特定操作的语言段;另外针对patran 宏命令语言不熟悉的人员,Patran中提供专门的宏命令录制工具,其操作路径为“File/Session/Record”。
以下针对第二种情况进行演示:(1). 启动patran,建立CAD模型。
(2). 使用MESH功能进行网格划分,在点击“Apply”之前,返回主菜单选择“File/Session/Record”(3). 开始记录Patran的操作命令流,指定会话文件“mesh.ses”。
(4). 在网格划分窗口点击“Apply”,创建网格。
(5). 从“File/Session/Record”点击“STOP”停止记录。
(6). 退出Patran。
2.生成PCL文件(1). 在记事本格式下打开文件“mesh.ses”文件,该文件在工作目录中。
(2). 删除文本中前缀为“$#”开头的语句。
(3). 在剩下语段的最前面加上“FUNCTION mesh”(4). 在剩下语段的最后面加上“END FUNCTION”(5). 将整理后的文件另存为“mesh.pcl”存放在Patran的工作目录中。
patran,PCL学习
PATRAN 304 Exercise Workbook11-1EXERCISE 11Objectives:sWrite a class to create a form with a single button.Create a Simple Form11-2PATRAN 304 Exercise WorkbookEXERCISE 11Create a New FormPATRAN 304 Exercise Workbook 11-3Exercise Description:This exercise,class push_me,creates a new form called Push Me which contains a single button called Push Me.When pressed the button will execute a function to write a text string to the command window.Files:All the files that used in this exercise are listed below.Each list includes the file,where it originated,and a summary of information of how it relates to the exercise.FileSupplied/CreatedDescriptionexercise_11.templateSuppliedA template file that you may use to fill in the missing PCL calls that should be added to the function.push.pcl CreatedThis file should be created after all the blanks are filled in the exercise_12.template file.p3epilog.pcl CreatedThis file should be created in order to input the proper files into PATRAN upon start up.Exercise Procedure:1.Edit the PCL function in the fileexercise_11.template .Replace the blanks with the appropriate PCL expressions. Rename the file to push_me.pcl when you are done.The dimension parameters used for the example are 5inches from the left and 1inch from the top of the upper left corner of the screen.The form is 2.5inches tall by 2.5inches wide.The button is located 0.5inches form the left and 1inch form the top of the form.The button is 1.5inches wide with default height.When pressed it calls a function to print “You have just programmed your First Form” to the command window.11-4PATRAN 304 Exercise WorkbookYou may also use the template file your instructor will provide for you to add the missing PCL code.2.Compile the function.Type in the command:p3pclcompEnter the command !!input push_me.pcl into the p3compiler.All the error messages and diagnostics will be written in the xterm window.If no errors are found in the function test the function in MSC/PATRAN.3.To test the function create a p3epilog.pcl file in the directory from which you are going to invoke p3. The file should contain:!!input push_me.pcl !!input training.pcl training.init ()4.Start PATRAN, by typing p3,in the directory in which you just created the p3epilog.pcl file.Push Me FormPush Me1.5”2.5”.5”2.5”1.0”EXAMPLEEXERCISE 11Create a New FormPATRAN 304 Exercise Workbook 11-5Pull down the Training menu in the Main Window.Select the Exercise 11option.When the form appears,press the Push Me button.Your form should appear as shown.Press the button,Push Me,which resultsin the following display in the command window:You have just programmed your First Form!!!Sample Solution:/*$$ Use of PCL in creating customized forms/widgets** Purpose:*Create a simple form with a Single button.** Input:*<None>** Output:*<None>** Log:** Notes:**/CLASS push_me/* Variable initialization */CLASSWIDE widget form_id, @push_me_buttonFUNCTION INIT()/** Create the form*//* Insert the values for these parameters */form_id=ui_form_create(@/*callback*/*****1*****@/*x*/*****1*****@/*y*/*****1*****@/*position*/*****1*****@/*width*/*****1*****@/*height*/*****1*****@/*label*/*****1*****@/*iconname*/*****1*****) /** Create the “Push Me” button*/push_me_button = ui_button_create(@/*parent*/*****2*****@/*callback*/*****2*****@/*x*/*****2*****@/*y*/*****2*****@/*width*/*****2*****@/*height*/*****2*****@/*label*/*****2*****@/*labelinside*/*****2*****@/*highlight*/*****2*****) END FUNCTIONFUNCTION DISPLAY()11-6PATRAN 304 Exercise WorkbookEXERCISE 11Create a New FormPATRAN 304 Exercise Workbook 11-7ui_form_display( *****3*****)END FUNCTIONFUNCTION push_me_cb()ui_write(“You have just programmed your First Form!!”)ui_form_hide( *****4*****)END FUNCTION END CLASSE1x e r c i s eWo r k b o o kN304PAA1-8TRNote:Each*1* ““, 5.0, 1.0, “UL”, 2.5, 2.5, “Push Me Form”, ““*2* form_id, “push_me_cb”, 0.5, 1.0, 1.5, 0.0, “Push Me”, TRUE, TRUE*3* “push_me”*4* “push_me”。
Patran操作步骤仅供参考,照搬的切小JJ
3.1.1创建数据库文件1)任务栏中点【File】,选择New,文件名输入yuan,点。
2)会出现如图3-1这样的一个选择项,Analysis Code下选项选择MSC.Nastran,Analysis Type下的选项选择Structural,点。
图3-1 创建文件选择区3.1.2创建几何模型1)任务栏中点【Geometry】,Action→Create,Object→Solid,Method→Primitive,点击按钮,弹出如图3-2所示菜单:图3-2 创建平板菜单栏2)设定长宽高X Length list→60, Y Length list→40, Z Length list→1, 选择基点Base Origin Point List→[-30 -20 0],点,得到如图3-3所示平板。
图3-3 创建平板3)创建圆柱:点击按钮,出现如图3-4所示菜单:图3-4 创建圆柱菜单栏4)设定圆柱高Height List→5,半径Radius List→2,基点Base Origin Point List →[0 0 0],点。
得到如图3-5所示模型:图3-5 带圆柱板5)【Geometry】菜单栏中,Action→Edit,Object→Solid,Method→Boolean,点击按钮,弹出如图3-6所示菜单:图3-6 Boolean菜单6)选中Target Solid下的命令框,左键单击平板,选中Subtracting Solid List 下命令框,左键单击圆柱,点,得到图3-7所示带圆孔板:图3-7 带圆孔板模型3.1.3有限元网络划分1)任务栏中点【Meshing】,Action→Create,Object→Mesh,Type→Solid,弹出如图3-8所示菜单:图3-8 有限元网络划分2)这里我们选用四面体自动划分网格Elem Shape→Ted, Mesher→TetMesh, Topology→Ted4, Input List→Solid 1,取消Automatic Calculation选项前的√,在Value后的命令框中输入1.0,点,得到图3-9模型。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
The default NT toolbars contain 32 icons
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
8-3
PATRAN Default Toolbar Icons
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
8-8
PATRAN Toolbar Functions
*CLASS and *FUNCTION specify the function that is to be used by the Icon in the Toolbar. CLASS and FUNCTION definitions can be specified by creating relatively simple PCL functions. PCL functions that reside within a user defined class are made available by referencing the library in the user’s p3epilog.pcl file.
Lecture 8 Customizing: Toolbar, p3printers.def, Keymapping, Creating an Analysis Preference
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
$
= 100 %
Image Size = Fit on Page, As Is Scale Factor = No Show; 1.0 Center = No Show; Yes Draw Borders $ Note use of “No Show” and a default
= Yes, No
8-10
p3printers.def (cont.)
The driver is also displayed in the p3printers.def file An example is shown below:
..........Driver Specific Options.................. Format Black to White, White to Black, Color Background White, Black, Actual Lines & Text = White, Black, Actual; Black Line Weight = 0.5 pts Text Scale $ Note use of default = $ another option is “Grayscale” =
The printers available on NT need to be set up through starndard Windows configuration. An example of the format is shown below: $This is the Default Postscript Printer Printer
End Toolbar
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
8-6
PATRAN Toolbar Control File (cont.)
The icons can be found in Patran_install_dir/icons directory. • • *CLASS indicates where to find the function for the icon. *FUNCTION indicates which function will be executed when the icon is selected. *HELP indicates the help bubble that will be displayed when the mouse moves over the icon.
•
There is also an option for whether or not to load the icon into the toolbar when PATRAN is executed. – In order for the icon to load into MSC.Patran, – *LOAD ITEM must be added after the *HELP call.
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. • tbblank.28.icon
8-4
PATRAN Default Toolbar Icons (cont.)
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
8-5
PATRAN Toolbar Control File
The Toolbar on the main form is configured by the p3toolbar.def file. p3toolbar.def is located in the MSC.Patran installation directory. The file is read in sequential order when the p3toolbar is displayed. • i.e., top to bottom in the file refers to the icons left to right on the toolbar
The user defined icons must be referenced in the p3toolbar.def file and must be in MSC.Patran’s path p3toolbar.def must be in either the Patran_install_dir or the users home directory
= Postscript Default
Print Orientation = Portrait, Landscape; Landscape $ Note use of default
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
p3toolbar.def file example: Start Toolbar = Transform *ICON= tbrotatexy.bmp *CLASS= uil_toolbar *FUNCTION= rotate_xy *HELP= Mouse Rotate XY *LOAD ITEM
Quality = No Show; Normal Color Model = No Show; RGB GCR = No Show; 75 %
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporation
8-11
Device Driver Destination Paper Size Width Height Left Margin Right Margin Top Margin Bottom Margin Default Units Number of Copies = Unknown = Postscript = Unknown = Letter, Custom = 0.0 = 0.0 = 0.5 in = 0.5 in = 0.5 in = 0.5 in = Inches, Points, cm = 1 $ Other units are Picas and mm $ See the documentation for additional sizes $ Default width for Custom paper size $ Default height for Custom paper size
The Start/End Toolbar Lines (NT only) define the boundaries of the dockable toolbars
PAT304 Course Notes – Release 9.5 Copyright 2001 MSC.Software Corporf (UNIX only)