Patran的PCL用户手册 - 图文(5)

2019-03-10 22:21

PCL for the more Adventurous

Adding a Graphical User Interface, GUI

?

The next step might be to create a user interface to run the plate session file!

#include “appforms.p” CLASS plate_hole /* classwide variables */ CLASSWIDE WIDGET main_form, description_btn, radius_dbox CLASSWIDE WIDGET sep1, apply_btn, cancel_btn FUNCTION init() REAL x_loc, y_loc main_form = ui_form_create( @ /* callback */ “”, @ /* x location */ FORM_X_LOC, @ /* y location */ FORM_Y_LOC, @ ... END FUNCTION /* init */ FUNCTION display() ui_form_display(“plate_hole”) END FUNCTION /* display */ FUNCTION apply_button_cb() GLOBAL REAL radius ui_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: apply_button_cb()

MSC.Patran PCL Workshop Notes 04/13/16 21/236

Exercise 1: Session Files

Use MSC.Patran to create a parameterized session file that creates a 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 line b) 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 sense

for the hole to be outside the surface boundary.

IF (x_center + diameter/2.0 > length) THEN RETURN

Extra credit: Include meshing, boundary conditions, element

properties, etc. Extra credit: Use ui_read_real(prompt) to enter the variable

values interactively Extra credit: Turn your session file into a PCL FUNCTION.

MSC.Patran PCL Workshop Notes 04/13/16 22/236

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 GUI 2) Variables and macros are persistent 3) Plus, more. See Appendix G for the details

MSC.Patran PCL Workshop Notes 04/13/16 23/236

PCL Programming Basics

Overview

? ?

PCL is a full-featured programming language.

Operators for arithmetic, relational, and string expressions. Examples include:

addition multiplication string concatenation logical or logical equal logical not equal + * // || == != ?

Variables with type, scope, and dimension attributes

INTEGER LOGICAL REAL GLOBAL STRING

i, j, status, NodeIds(1000) flag

xyz(1000, 3), pressure(100), time my_group[32], all_groups[32](100)

?

Dynamically allocated virtual strings and arrays

INTEGER STRING

node_ids(VIRTUAL)

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])

MSC.Patran PCL Workshop Notes 04/13/16 24/236

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 files

text_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)

MSC.Patran PCL Workshop Notes 04/13/16 25/236


Patran的PCL用户手册 - 图文(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:12年7月劳动法串讲资料

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: