精典材料Patran的PCL用户手册V20_第1页
精典材料Patran的PCL用户手册V20_第2页
精典材料Patran的PCL用户手册V20_第3页
精典材料Patran的PCL用户手册V20_第4页
精典材料Patran的PCL用户手册V20_第5页
已阅读5页,还剩229页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、FUNCTION init() WIDGET id INTEGER i, status REAL x_loc, y_loc, form_width, form_height REAL frame_width REAL f_width, half_space STRING version3 STRING method_optNAME_LENGTH, methodNAME_LENGTH form_width = FORM_WID_SML frame_width = form_width - FORM_L_MARGIN - FORM_R_MARGIN f_width = frame_width -

2、FRAME_L_MARGIN - FRAME_R_MARGIN - FRAME_2EDGE half_space = INTER_WIDGET_SPACE/2.0settings.pclp3prolog.pclp3midilog.pclp3epilog.pcl.Patran.EventMapsMSC.Patran PCL HandbookIn a Nutshell7What is PCL?7What can PCL be used for?8How does PCL work?9All you really need to know is on this page!10Documentatio

3、n10PCL for Everyone11Entering Equations11Entering Data12Session Files13Rebuilding Models14PCL for the More Adventurous17Parametric Modeling17Adding a Graphical User Interface, GUI21Exercise 1: Session Files22PCL Programming Basics24Overview24PCL Expressions26Expressions, Comments, Syntax Tips26Ident

4、ifiers28Naming Conventions28Variable / Function Scope28Structure of a PCL Function28Function Basics28Simple PCL function Example28Exercise 2: Hello World!28Exercise 3: Effective PCL28PCL Operators28String comparisons28PCL Variables and Constants28Datatypes28Variable Scope28Directly Allocated Arrays2

5、8Virtual arrays28Virtual strings28Loop Control Statements28For Loop28While Loop28Repeat Loop28BREAK28CONTINUE28Exercise 4: Writing Files28Exercise 5: Reading Files28Conditional Control Statements28IF Statement28SWITCH Statement28Structure of a PCL Function28Compiling and Linking PCL Functions28Prima

6、ry PCL Directives28Compiling PCL outside of MSC.Patran28Linking Compiled Libraries28Other PCL Directives28Start Up Files28Exercise 6: p3epilog.pcl28Debugging28Debugging Compile Errors28Debugging Runtime Errors28Accessing PCL Functions28From The Command Line28From Any MSC.Patran Form28PCL Functions w

7、ith Field Variables28MSC.Patran Built-In Functions28Naming Conventions for Applications28Naming Conventions for Other Operations28Exercise 7: Group Elements By Shape28Graphical User Interface28The PCL Class Statement28PCL Widgets28Required Functions for Building/Displaying a Form28The init() Functio

8、n28The display() Function28Widget Callbacks28What Are They?28What Are They Used For?28Callback Arguments (Widget Function Data)28Widget Placement28Widget Variables28Modifying Widgets28Getting Data from Widgets28Putting it all Together (Example)28Exercise 8: Simple Form28The C-Preprocessor and Includ

9、e Files28Make Files28Exercise 9: Callbacks28Handling Errors and Messaging28Errors from Built-In Functions28Custom Error Messages28Using User Messages Database28Without a Messages Database28Taking Advantage of the UNDO Feature28Select Mechanism28Select Mechanism GUI Mechanics28Select Databoxes, Selec

10、t Frames, and Select Menus28GUI PCL Example28List Processor28List Processor Mechanics28All You Really Need to Know28Exercise 10: Form to Group Elms By Shape28Executing Programs Outside of MSC.Patran28Spawning Remote Processes28Locking a database28Using C and Fortran executables to access a MSC.Patra

11、n database directly.28External Access of an MSC.Patran Database28Special Widgets28File Widget28Spreadsheet Widget28Exercise 11: File Widget28Adding Help/Description to your PCL28Percent Complete28Functions28Example28Event Manager28General28Functions28Example28Primitive Graphics28Graphic Objects28Gra

12、phic Segments28Example28Another Example28Exercise 12: Primitive Graphics28MSC.Patran Customization28Adding Utility Programs to the Main Menu28Example2828Customizing the MSC.Patran Toolbar28Exercise 13: Pulldown Menu28Exercise 14: Toolbar28Some Final Thoughts28Appendix A28Built-in Function Examples28

13、Documentation for a typical MSC.Patran built-in function.28To get all the nodes and their global coordinates28To get the topology of every element28To get the shape of every element28To get all the element connectivity for all elements28To get the elements associated to a particular element property

14、 set28To get an element property value (shell thickness) for a specific element28To get a material property value28To get a list of all groups28To get the nodes and elements associated to the current group28To get result values for specified elements28Appendix B28Strings & String Functions28Declarat

15、ion28Initialization28String Comparisons28Functions28Appendix C28Noteworthy Functions28sys_move_raw()28mth_array_search()28mth_sort()28mth_sort_row()28mth_sort_column()28fem_geom_edge_length()28fem_geom_face_area()28fem_geom_elem_volume()28fem_geom_elem_location()28Appendix D28Form Spacing Parameters

16、 (appforms.p)28* SPACING28Appendix E28MSC.Patran Architecture28Appendix F28Shareware Compiling Functions28Appendix G28Parametric Patran28Appendix H28Additional List Processor Notes28List Processor Mechanics28List Processor Functions28List Processor Sublist Functions28List Processor Attribute Functio

17、ns28Miscellaneous List Processor Functions28List Processor Examples28Easy to Use List Processor Functions28Appendix I28Key Mapping28Appendix J28Widget Classification28Appendix K28User Defined AOM28In a NutshellWhat is PCL?q PCL stands for Patran Command Languageq Comprehensive, fully functional comp

18、uter programming languageq Specifically and uniquely suited for MCAE applicationsq Delivered as a part of MSC.Patranq Versatile and easy to useIn a NutshellWhat can PCL be used for?q Integrate application or site-specific programs with the MSC.Patran user interface and databaseq Generate parametric/

19、variational models for design/optimizationq Integrate commercial and/or in-house analysis codes with MSC.Patranq Display custom graphicsq Access the MSC.Patran databaseq Create new and/or enhanced MSC.Patran functionalityq Database management for analysis filesq Eliminate tedious, repetitive procedu

20、resIn a NutshellHow does PCL work?q All MSC.Patran commands are first interpreted by the PCL command interpreterq PCL expressions are interpreted by a C programq PCL functions can be compiled into libraries (more efficient binary representation) and “linked” with a MSC.Patran sessionq “Built-in” PCL

21、 functions are written in C or FORTRANq MSC.Patran forms and menus can be created via PCL calls to Xlib, the X-window function libraryYouMSC.PatranOtherFortranC, C+PCLq FORTRAN and C functions can be “linked” with MSC.Patran through PCLIn a NutshellAll you really need to know is on this page!Documen

22、tationq PCL and Customization - General programming guide for PCL. How to build forms, compile, manage libraries, access the database, read/write files, etc.q PCL Reference Description of functions written to the session file.q Develop: The MSC.Patran Toolkit Documentation of additional functions fo

23、r database access, etc.Programming TaskDocumentationCommentsBasic programmingPCL & Customization, chapters 2 & 3Math functions, string functions, file access functions, compiling, library management, etc.Graphical user interfacePCL & Customization, chapter 5Functions for creating formsList processor

24、PCL & Customization, chapter 5.5Functions for parsing a string or picklist, i.e., “Elm 1:9:2”Applications, session file, result utilitiesPCL Reference GuideAll functions written to the session fileGraphicsPCL & Customization, chapter 3.2Functions for drawing graphic primitives such as lines, arrows,

25、 text, etc.Database functionsPCL & Customization, chapter 8Functions to access data in the database (i.e., node coordinates, element connectivity, element properties, etc.)ArchitecturePCL & Customization, chapters 6 & 7Functions for creating analysis preferencesPCL for EveryoneEntering Equationsq Us

26、e of PCL when creating spatial fields:X + X*2 sinr(X)The PCL interpreter interprets anything immediately following a symbol as a field variable as opposed to a PCL function, such as, sinr().PCL for EveryoneEntering Dataq Use of PCL when entering geometric coordinates: 5./16. 0 0 The PCL interpreter

27、“evaluates” expressions enclosed in back tics, “”.Other examples: radius/length 0 0 MyFunction(radius) 0 1 PCL for EveryoneSession Filesq Session and journal files are comprised entirely of PCL commands. Model changes (dimensions, mesh density, etc.) can be made quickly by editing and then replaying

28、 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_idsVIRTUALasm_const_patch_xyz( 1, , 0 0 0, Coord 0, asm_create_patch_xy_created_ids )$# 1 Patch created: Patch 1STRING sgm_edit_surface

29、_add_h_edit_idsVIRTUALsgm_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:52PCL for EveryoneRebuilding Modelsq The following session file creates a trimmed surf

30、ace, 10” x10” with a 1” diameter hole at the center. Note that the parameter that controls the diameter of the hole is indicated below.A.$# Session file patran.ses.01 started recording at 16-Aug-01 14:33:54$# Recorded by: MSC.Patran 2001STRING asm_create_patch_xy_created_idsVIRTUALasm_const_patch_xy

31、z( 1, , 0 0 0, Coord 0, B.asm_create_patch_xy_created_ids )$# 1 Patch created: Patch 1STRING sgm_edit_surface_add_h_edit_idsVIRTUALsgm_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 record

32、ing at 16-Aug-01 14:34:52A. Create/Surface/XYZB. Edit/Surface/Add HolePCL for Everyoneq In 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 a

33、sm_create_patch_xy_created_idsVIRTUALasm_const_patch_xyz( 1, , 0 0 0, Coord 0, asm_create_patch_xy_created_ids )$# 1 Patch created: Patch 1STRING sgm_edit_surface_add_h_edit_idsVIRTUALsgm_edit_surface_add_hole( 1, 4., TRUE, , 5 5 0, , Surface 1, sgm_edit_surface_add_h_edit_ids )$# 1 Surface Edited:

34、Surface 1$# Session file patran.ses.01 stopped recording at 16-Aug-01 14:34:52PCL for EveryoneIf “Single Step” is selected, each command in the session file is written to the MSC.Patran command line. You must hit the enter key to execute the command. If it is not selected, then all of the PCL comman

35、ds in the session file are executed automatically.If “Commit Commands” is selected, then each command in the session file being executed is also written to the session file which is currently being recorded. Otherwise, only the sf_play() command is written to the session file being recorded.q Sessio

36、n files can be executed or “played” by selecting File/Session/Play from the top menu.PCL for the More AdventurousParametric Modelingq Session files can be parameterized by defining and using variables during the MSC.Patran sessionThe variable “radius” declared as a REAL numberThe variable “radius” i

37、s initialized to 1q First, variables are declared and initialized via the MSC.Patran command linePCL for the more Adventurousq Second, the variables are used as input into the appropriate MSC.Patran forms (note the use of , back tics)PCL for the more Adventurousq Upon application, the PCL interprete

38、r 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 unevaluated form.PCL for the more Adventurous$# Session file patran.ses.01 started recording at 16-Aug-01 14:33:54$# Recorded by: MSC.Patran 2001REAL rad

39、iusradius = 1.0STRING asm_create_patch_xy_created_idsVIRTUALasm_const_patch_xyz( 1, , 0 0 0, Coord 0, asm_create_patch_xy_created_ids )$# 1 Patch created: Patch 1STRING sgm_edit_surface_add_h_edit_idsVIRTUALsgm_edit_surface_add_hole( 1, radius , TRUE, , 5 5 0, , Surface 1, sgm_edit_surface_add_h_edi

40、t_ids )$# 1 Surface Edited: Surface 1$# Session file patran.ses.01 stopped recording at 16-Aug-01 14:34:52q By 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#include “appform

41、s.p”CLASS plate_hole/* classwide variables */CLASSWIDE WIDGET main_form, description_btn, radius_dboxCLASSWIDE WIDGET sep1, apply_btn, cancel_btnFUNCTION init()REAL x_loc, y_locmain_form = ui_form_create( /* callback */ “”, /* x location */ FORM_X_LOC, /* y location */ FORM_Y_LOC, .END FUNCTION /* i

42、nit */FUNCTION display()ui_form_display(“plate_hole”)END FUNCTION /* display */FUNCTION apply_button_cb()GLOBAL REAL radiusui_wid_get(radius_dbox, “VALUE”, radius)sf_play(“plate_hole.ses”)END FUNCTION /* apply_button_cb */END CLASS /* plate_hole */Hitting the “Apply” button executes the function: ap

43、ply_button_cb()Adding a Graphical User Interface, GUIq The 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 creates a rectangular surface with an arbitrarily located hole.1) Create variable

44、s for the dimensions shown below.2) Steps:a) Create variables using MSC.Patrans 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 doesnt make sense for the hole to be outside

45、the surface boundary.IF (x_center + diameter/2.0 length) THEN RETURNExtra credit:Include meshing, boundary conditions, element properties, etc.Extra credit:Use ui_read_real(prompt) to enter the variable values interactivelyExtra credit:Turn your session file into a PCL FUNCTION.Exercise 1Below is an

46、 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 Pro

47、gramming BasicsOverviewq PCL is a full-featured programming language.q Operators for arithmetic, relational, and string expressions. Examples include:addition+multiplication*string concatenation/logical or|logical equal=logical not equal!=q Variables with type, scope, and dimension attributesINTEGER

48、 i, j, status, NodeIds(1000)LOGICALflagREALxyz(1000, 3), pressure(100), timeGLOBAL STRINGmy_group32, all_groups32(100)q Dynamically allocated virtual strings and arraysINTEGERnode_ids(VIRTUAL)STRINGgroups32(VIRTUAL), MyStringVIRTUALq Intrinsic functions for math, string manipulation, etc.sinr(angle)

49、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 Basicsq

50、Loop control features, such as, WHILE, FOR, REPEAT, and LISTq Conditional control structure, such as, IF-THEN-ELSE and SWITCH-CASEq Subroutine (procedure) and function (command) callsq Class grouping of related functionsq Read/write access to external ASCII and/or binary filestext_open(FileName, Opt

51、ions, 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)q Access

52、 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 ExpressionsExpressions,

53、Comments, Syntax Tipsq 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)q PCL comments begin with a “/*” and end with a “*/”/*This is a comment.Look Ma, Im making comments in PCL!Has anyon

54、e seen or heard from Elvis lately?*/a = 2 /* set mysterious factor equal to 2 */q Alternatively, single line comments may begin with “$”$ Dont you just hate to comment your programs?q More than one PCL expression can co-exist on a line using a semi-colon, “;”alpha = 30.0; beta = 120.0q 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 Expressionsq Dont break expre

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论