Professional Documents
Culture Documents
FUNCTION init()
WIDGET id
INTEGER i, status
STRING version[3]
STRING method_opt[NAME_LENGTH], method[NAME_LENGTH]
form_width = FORM_WID_SML
frame_width = form_width - FORM_L_MARGIN - FORM_R_MARGIN
f_width = frame_width - FRAME_L_MARGIN - @
FRAME_R_MARGIN - FRAME_2EDGE
half_space = INTER_WIDGET_SPACE/2.0
settings.pcl
p3prolog.pcl
p3midilog.pcl
p3epilog.pcl
.Patran.EventMaps
In a Nutshell...................................................................................................................................6
What is PCL?........................................................................................................................................................ 6
What can PCL be used for?................................................................................................................................ 7
How does PCL work?.......................................................................................................................................... 8
All you really need to know is on this page!...................................................................................................... 9
Documentation......................................................................................................................................................................9
PCL Expressions........................................................................................................................25
Expressions, Comments, Syntax Tips............................................................................................................. 25
Identifiers.....................................................................................................................................27
Naming Conventions......................................................................................................................................... 27
Variable / Function Scope................................................................................................................................. 28
PCL Operators.............................................................................................................................34
String comparisons........................................................................................................................................... 34
Exercise 6: p3epilog.pcl.............................................................................................................62
Debugging...................................................................................................................................63
Debugging Compile Errors............................................................................................................................... 63
Debugging Runtime Errors............................................................................................................................... 64
Exercise 9: Callbacks.................................................................................................................95
Select Mechanism.....................................................................................................................102
Select Mechanism GUI Mechanics................................................................................................................. 102
Select Databoxes, Select Frames, and Select Menus........................................................................................................102
GUI PCL Example............................................................................................................................................................104
List Processor.................................................................................................................................................. 105
List Processor Mechanics.................................................................................................................................................105
All You Really Need to Know..........................................................................................................................................106
Special Widgets.........................................................................................................................117
File Widget........................................................................................................................................................ 117
Spreadsheet Widget......................................................................................................................................... 120
Percent Complete.....................................................................................................................123
Functions.......................................................................................................................................................... 123
Example............................................................................................................................................................ 123
Event Manager..........................................................................................................................124
MSC.Patran PCL Workshop Notes 05/05/17
4/252
General............................................................................................................................................................. 124
Functions.......................................................................................................................................................... 125
Example............................................................................................................................................................ 125
Primitive Graphics....................................................................................................................126
Graphic Objects............................................................................................................................................... 126
Graphic Segments........................................................................................................................................... 127
Example............................................................................................................................................................ 128
Another Example............................................................................................................................................. 129
MSC.Patran Customization......................................................................................................131
Adding Utility Programs to the Main Menu.................................................................................................... 131
Example............................................................................................................................................................................132
Example: p3_user_menu.my_menu.def...........................................................................................................................133
Customizing the MSC.Patran Toolbar............................................................................................................ 134
Appendix A................................................................................................................................143
Built-in Function Examples............................................................................................................................. 143
Documentation for a typical MSC.Patran built-in function...........................................................................144
To get all the nodes and their global coordinates.........................................................................................145
To get the topology of every element............................................................................................................. 146
To get the shape of every element.................................................................................................................. 147
To get all the element connectivity for all elements......................................................................................148
To get the elements associated to a particular element property set.........................................................149
To get an element property value (shell thickness) for a specific element.................................................150
To get a material property value..................................................................................................................... 152
To get a list of all groups................................................................................................................................. 153
To get the nodes and elements associated to the current group................................................................153
To get result values for specified elements................................................................................................... 154
Appendix B................................................................................................................................163
Strings & String Functions.............................................................................................................................. 163
Declaration....................................................................................................................................................... 164
Initialization...................................................................................................................................................... 164
String Comparisons......................................................................................................................................... 164
Functions.......................................................................................................................................................... 165
Appendix C................................................................................................................................173
Noteworthy Functions..................................................................................................................................... 173
sys_move_raw()........................................................................................................................................... 174
mth_array_search()...................................................................................................................................... 175
mth_sort()...................................................................................................................................................... 176
mth_sort_row()............................................................................................................................................. 177
mth_sort_column()....................................................................................................................................... 177
Appendix D................................................................................................................................180
Form Spacing Parameters (appforms.p)........................................................................................................ 180
* SPACING.................................................................................................................................................. 181
Appendix E................................................................................................................................206
MSC.Patran Architecture................................................................................................................................. 206
Appendix F................................................................................................................................208
Shareware Compiling Functions.................................................................................................................... 208
Appendix G................................................................................................................................211
Parametric Patran............................................................................................................................................ 211
Appendix H................................................................................................................................217
Additional List Processor Notes..................................................................................................................... 217
List Processor Mechanics.................................................................................................................................................218
List Processor Functions...................................................................................................................................................219
List Processor Sublist Functions.......................................................................................................................................220
List Processor Attribute Functions...................................................................................................................................221
Miscellaneous List Processor Functions...........................................................................................................................222
List Processor Examples...................................................................................................................................................223
Easy to Use List Processor Functions...............................................................................................................................227
Appendix I..................................................................................................................................228
Key Mapping..................................................................................................................................................... 228
Appendix J.................................................................................................................................231
Widget Classification....................................................................................................................................... 231
Appendix K................................................................................................................................234
User Defined AOM............................................................................................................................................ 234
What is PCL?
You
MSC.Patran
PCL
Graphical user interface PCL & Customization, chapter 5 Functions for creating forms
List processor PCL & Customization, chapter Functions for parsing a string
5.5 or picklist, i.e., Elm 1:9:2
Applications, session file, PCL Reference Guide All functions written to the
result utilities session file
Graphics PCL & Customization, chapter Functions for drawing graphic
3.2 primitives such as lines,
arrows, text, etc.
Database functions PCL & Customization, chapter 8 Functions to access data in
the database (i.e., node
coordinates, element
connectivity, element
properties, etc.)
Architecture PCL & Customization, chapters 6 Functions for creating analysis
&7 preferences
Entering Equations
X + X**2 sinr(X)
Entering Data
[ `5./16.` 0 0 ]
Other examples:
[ `radius/length` 0 0 ]
< `cosr(theta)` 1 1 >
[ `MyFunction(radius)` 0 1 ]
Session Files
Rebuilding Models
A. Create/Surface/XYZ
B. Edit/Surface/Add Hole
Parametric Modeling
#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)
FUNCTION apply_button_cb()
sf_play(plate_hole.ses)
2) Steps:
a) Create variables using MSC.Patrans command line
b) Create/Surface/XYZ (use variables length and width)
c) Edit/Surface/Add Hole (use x_center, y_center, and diameter)
Overview
addition +
multiplication *
string concatenation //
logical or ||
logical equal ==
logical not equal !=
Naming Conventions
Invalid identifiers
a_very_very_very_very_very_very_very_very_long_name
95abc
list
Function Basics
FUNCTION a_very_simple_function()
/* This is a comment. */
$ This is also a comment.
Variable declaration
INTEGER MyFavoriteNumber
MyFavoriteNumber = 29 Variable initialization
ui_writec(My favorite number is %d \n, MyFavoriteNumber)
ui_writef(A21,1X,I3, My favorite number is, MyFavoriteNumber)
ui_write(My favorite number is //STR_FROM_INTEGER(MyFavoriteNumber))
Function terminator
Calling statement
FUNCTION another_simple_function(MyFavoriteNumber)
INTEGER MyFavoriteNumber
INTEGER MyLeastFavoriteNumber
MyLeastFavoriteNumber = 13
ui_write(My favorite number is //str_from_integer(MyFavoriteNumber))
ui_write(My least favorite number is // @
str_from_integer(MyLeastFavoriteNumber))
END FUNCTION /* another_simple_function */
Operators Comments
+ - ! Unary plus, minus, logical not
** Exponentiation
* / Multiplication and division
+ - Additions and subtraction
// String concatenation
< > <= >= == != Relational operators
|| && Logical or, logical and
+= -= = Increment, decrement, assignment
Examples
Dist = mth_sqrt((x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2)
MyString3 = MyString2//hijk
IF (a == b) THEN c = d
IF (a == b && a == c) THEN ui_write(Equilibrium)
x += 1 (this is equivalent to x = x + 1)
String comparisons
Datatypes
Variable Scope
GLOBAL REAL a, b, c
CLASS training
CLASSWIDE REAL d, e
Array dimensions are inherited from the argument list, i.e., PCL
passes by reference
FUNCTION MyFunc()
STRING MyString[32](32)
FUNCTION YourFunc(MyVal)
YourFunc(MyString)
STRING MyVal[]()
END FUNCTION
END FUNCTION
Declaration Examples
Virtual arrays
REAL MyVals(VIRTUAL)
INTEGER NodeIds(VIRTUAL)
INTEGER i, j, status
INTEGER num_nodes, node_ids()
INTEGER num_db_nodes, db_node_ids(VIRTUAL)
LOGICAL found_node
RETURN 0
Virtual strings
STRING picklist[VIRTUAL]
For Loop
Syntax
FOR (var=numeric_expr TO numeric_expr [BY numeric_expr]) [label]
statements
END FOR
AvgTemp = 0.0
FOR (i = 1 TO NumNodes)
AvgTemp += NodalTemp(i)
END FOR
AvgTemp = AvgTemp/NumNodes
While Loop
Syntax
WHILE (logical_expression) [label]
statements
END WHILE
Example
AvgTemp = 0.0
i = 1
WHILE (i <= NumNodes)
AvgTemp += NodalTemp(i)
i += 1
END WHILE
AvgTemp = AvgTemp/NumNodes
Repeat Loop
REPEAT [label]
statements
UNTIL (logical_expression)
Example
AvgTemp = 0.0
i = 1
REPEAT
AvgTemp += NodalTemp(i)
i += 1
UNTIL (i > NumNodes)
AvgTemp = AvgTemp/NumNodes
BREAK
END WHILE
statements
END WHILE
statements
END WHILE
statements
CONTINUE
The CONTINUE statement is used to skip to the end of the loop
Syntax
CONTINUE [label]
REPEAT InnerLoop
CONTINUE MainLoop
BREAK InnerLoop
CONTINUE
CONTINUE InnerLoop
END WHILE
statements
Extra credit: Include a header line at the top of the file that
includes the filename and the total number of nodes
written to the file.
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)
IF Statement
Syntax
IF (logical_expression) THEN
statements
ELSE IF (logical_expression) THEN
statements
ELSE
statements
END IF
Example
IF (MyKeyWord == CBAR || MyKeyWord == CBEAM) THEN
statements
ELSE IF (MyKeyWord == CTRIA || MyKeyWord == CQUAD) THEN
statements
ELSE IF (MyKeyWord == GRID) THEN
statements
ELSE
statements
END IF
SWITCH Statement
Syntax
Example
Note that this SWITCH
SWITCH (EntityType) statement is equivalent to the
CASE (CBAR, CBEAM) IF statement on the previous
page.
statements
CASE (CTRIA, CQUAD)
statements
CASE (GRID)
statements
DEFAULT
statements
END SWITCH
FUNCTION calling_function()
$#NumIn = 5.0
$#NumOut = 8.14 Sample output
$#Var2 = 8.14
FUNCTION calling_subroutine2()
MyVal = DotProduct(a, b)
ui_write(Dot product = //STR_FROM_REAL(MyVal))
RETURN val
Calling statement
calling_subroutine2()
FUNCTION calling_subroutine3()
INTEGER status
REAL NumIn, NumOut
RETURN status
NumOut = MTH_SQRT(NumIn)
RETURN 0
The file (test.pcl) contained a FUNCTION statement. Therefore, MSC.Patran compiled the statements
between the FUNCTION statement and the END FUNCTION statement.
Typically, the filename will have a .pcl extension and the PCL
library file will have a .plb extension. If you do not specify a
library file, MSC.Patran will compile the filename into a library
file with the same name as the input file and a .plb extension.
Example usage
Example usage
!!LIB MyFunctions.plb
!!LIB YourFunctions.plb
Start Up Files
The contents of these files are usually very simple and often
just contain a few !!PATH and !!LIB directives.
$ Sample p3epilog.pcl file
!!PATH /msc/patran_common
!!PATH ~/patran_pcl, ~/patran_pcl/plb, ~/patran_pcl/icons
!!LIB MyFunctions.plb
!!LIB YourFunctions.plb
INTEGER i, j
INTEGER a(3)
FOR (i = 1 to 3)
a(i) = i
END FOR
j = 9
dump j, a
END FUNCTION
$# INTEGER j = 9
$# INTEGER a(3) = [1, 2, 3]
This can be used to find the line where the error occurred, but
there is no information about what the error is. In this example,
the error occurred with the built in function UI_ITEM_DELETEALL
on line 294 in function MSC_EXPLORE.REFRESH().
If the PCL function failure causes a MSC.Patran crash, then the
only debugging tools that can be used are ones that write to
the background window or STDOUT. These are !!DEBUG and
!!TRACE as mentioned before and another write statement that
outputs to STDOUT.
!I am about to call my_function and i = `i`
The line starts with a single ! and any variable between the
` marks are evaluated.
My_function(radius, sind(90))
REAL radius
radius = 2.5
My_function(radius, sind(90))
In this case the function does not get surrounded with back ticks,
but the field variables are each prefixed with a forward tick .
FUNCTION max_pressure(x,y,z,t)
REAL x,y,z,t
REAL pressure
RETURN pressure
END FUNCTION
Prefix Application
asm_ or sgm_ Geometry
loadsbcs_ Loads/BCs
res_ Results
insight_ Insight
xy_ XY Plot
list_ Tools/List
pref_ Preferences
fields_ Fields
loadcase_ Loadcases
Prefix Operations
db_ add and retrieve from the MSC.Patran database
FUNCTION init()
END FUNCTION /* init /
.
.
FUNCTION display()
END FUNCTION /* display */
.
.
END CLASS /* end of I_have_class */
PCL Widgets
Based on Motif Xlib and Xtlib intrinsics (UNIX) and Windows GUI (NT).
Form Label
Databox Label
Button 1 Button 2
Every form is defined within a class and has at least two, but
usually more specific functions; init(), display(). Sometimes the
refresh() function is also required.
my_button = ui_button_create( @
/* parent */ main_form, @
/* callback */ my_button_cb, @
/* x position */ FORM_L_MARGIN, @
/* y position */ y_loc, @
/* width */ BUTTON_WID_FULL, @
/* height */ BUTTON_HGT, @
/* label */ My Button, @
/* unused */ , @
/* highlight */ FALSE)
ui_form_display(my_class)
END FUNCTION
It is also used to hide and display widgets that are not always
visible:
IF (flag_advanced == TRUE) THEN
END IF
INTEGER db_status
STRING current_analysis_code[32]
db_status_ = db_get_default_anal_code(current_analysis_code)
ui_wid_set(analysis_code,LABEL,current_analysis_code)
END FUNCTION
Widget Heirarchy
Widgets are created in a hierarchical manner. Every widget
has a parent except the form.
main_form = ui_form_create( @
/* callback */ "", @
/* x position */ FORM_X_LOC, @
/* y position */ FORM_Y_LOC, @
/* relative to */ "UL", @
/* width */ FORM_WID_SML, @
/* height */ FORM_HGT_QTR, @
/* label */ "Form Label", @
/* unused */ "")
my_button = ui_button_create( @
/* parent */ main_form, @
/* callback */ "my_button_cb", @
/* x position */ FORM_L_MARGIN, @
/* y position */ y_location, )
All widgets could be children of the form, but widgets can also
be children of other widgets.
my_frame = ui_frame_create( @
/* parent */ main_form, @
/* callback */ , @
/* x position */ x_loc, @
/* y position */ y_loc, @
/* width */ FORM_WID_SML, )
inner_button = ui_button_create( @
/* parent */ my_frame, @
/* callback */ "inner_button_cb", @
/* x position */ FRAME_L_MARGIN, @
/* y position */ y_loc, @
/* width */ BUTTON_WID_FULL, @
/* height */ BUTTON_HGT, )
Widget Callbacks
What Are They?
ui_exec_function("another_form", display)
END FUNCTION
Callbacks are NOT required and most of the time they are not
used. When no immediate action is required, put an empty
string () for the callback name.
Callbacks are usually used to make changes to the form or
bring up another form based on user interaction.
Widget Placement
FORM_T_MARGIN
FORM LABEL
FRAME_LABEL_HGT
OPT_MENU_HGT
Menu Label: Menu item
INTER_WIDGET_SPACE
OPT_MENU_HGT
Menu Label: Menu item
FRAME_B_MARGIN
FRAME_1EDGE
INTER_WIDGET_SPACE
Databox Label
DBOX_HGT_LABOVE
INTER_WIDGET_SPACE
BUTTON_HGT
Button 1 Button 2
FORM_B_MARGIN
FORM_L_MARGIN FORM_R_MARGIN
dbox_id = ui_databox_create( @
/* parent */ my_frame, @
/* callback */ "", @
/* x position */ FORM_L_MARGIN, @
/* y position */ y_loc,)
apply_btn = ui_button_create( @
/* parent */ my_frame, @
/* callback */ "apply_btn_cb", @
/* x position */ FRAME_L_MARGIN, @
/* y position */ y_loc, @
/* width */ BUTTON_WID_HALF, @
/* height */ 0, )
Widget Variables
FUNCTION init()
.
.
my_frame = ui_frame_create( @
/* parent */ main_form, @
/* callback */ , @
/* x position */ x_loc, @
/* y position */ y_loc, @
/* width */ "FORM_WID_SML, )
Modifying Widgets
ga_display_shrfem_set(general, shrink_value)
END FUNCTION
ga_display_shrfem_set(general, shrink_value)
CLASS first_class
FUNCTION init()
REAL y_loc
main_form = ui_form_create( @
/* callback */ "", @
/* x position */ FORM_X_LOC, @
/* y position */ FORM_Y_LOC, @
/* relative to */ "UL", @
/* width */ FORM_WID_SML, @
/* height */ 0, @
/* label */ "Form Label", @
/* unused */ "")
y_loc = FORM_T_MARGIN
my_dbox = ui_databox_create( @
/* parent */ main_form, @
/* callback */ "", @
/* x position */ FORM_L_MARGIN, @
/* y position */ y_loc, @
/* label length */ 0, @
/* box length */ DBOX_WID_SINGLE, @
/* label */ "Enter a Value", @
/* value */ "", @
/* label above */ TRUE, @
/* datatype */ "REAL", @
/* number of values */ 1)
apply_btn = ui_button_create( @
/* parent */ main_form, @
/* callback */ "apply_btn_cb", @
/* x position */ BUTTON_THIRD_X_LOC1, @
/* y position */ y_loc, @
/* width */ BUTTON_WID_THIRD, @
/* height */ 0, @
/* label */ "Apply", @
/* unused */ TRUE, @
/* highlight */ TRUE)
ui_wid_set(main_form,"HEIGHT",y_loc)
FUNCTION display()
ui_form_display("first_class")
FUNCTION refresh()
FUNCTION apply_btn_cb()
FUNCTION cancel_btn_cb()
ui_form_hide("first_class")
Write a PCL class that creates a simple form with a single button
on it. Pressing the button should display a message in the
MSC.Patran history window, e.g., Help me Im being pushed
around!
1) Built-in functions:
ui_form_create(callback, x_loc, y_loc, position, width, @
height, label, iconname)
ui_button_create(parent, callback, x_loc, y_loc, width, @
height, label, flag, highlight)
ui_form_display(classname)
The constants to define the standard widget sizes and spacing are
defined in the include file appforms.p (see Appendix D). These
definitions are linked into your file by using the C-preprocessor
statement #include.
#include appforms.p
Make Files
FORM_X_LOC, FORM_Y_LOC
Message
OK
IF (num_elems == 0) THEN
user_message(Warn, 0, My PCL, No elements in the database!)
RETURN 0
END IF
Message
Warning reported in application My PCL
IF (file_exists(fname, )) THEN
status = user_message(C_YN, 0, PCL: Field Tool, @
Selected file already exists! Overwrite?)
file_delete(fname)
END IF
FUNCTION apply_btn_cb()
INTEGER status
REAL force_val
STRING lbc_name[32]
STRING node_list[VIRTUAL]
FUNCTION cancel_cb()
select_focus.exit()
ui_form_hide( CLASSNAME )
END FUNCTION
Together, the Select Databox, Select Frame, and Select Menu
are referred to as the select mechanism. The PCL widget
functions for a select mechanism are:
ui_selectframe_create(), ui_selectdatabox_create()
Auo Execute
Select Frame
List Processor
List Processor Mechanics
Usage: fem_u_count_id_list()
num_ids = fem_u_count_id_list(sublist_type, picklist, @
do_message, status)
INPUT:
sublist_type INTEGER See note below
picklist STRING
do_message LOGICAL
status INTEGER
OUTPUT:
num_ids INTEGER
Usage: fem_u_get_id_list()
fem_u_get_id_list(sublist_type, picklist, num_ids, @
do_message, ids)
Example
FUNCTION apply_cb()
INTEGER status
STRING node_list[VIRTUAL]
status = do_something_spectacular(node_list)
FUNCTION do_something_spectacular(node_list)
INTEGER status
INTEGER num_nodes, node_ids(VIRTUAL)
STRING node_list[]
num_nodes = fem_u_count_id_list(LP_SUBLIST_NODE, @
node_list, FALSE, status)
IF (num_nodes == 0) THEN RETURN (-1)
sys_allocate_array(node_ids, 1, num_nodes)
fem_u_get_id_list(LP_SUBLIST_NODE, node_list, @
num_nodes, FALSE, node_ids)
RETURN (0)
4) Built-in functions
ui_form_create(callback, x_loc, y_loc, position, width, height, label, iconnme)
ui_frame_create(parent, callback, x_loc, y_loc, label)
ui_switch_create(parent, callback, x_loc, y_loc, num_cols, label, always_one)
ui_item_create(parent, name, label, toggleable)
ui_databox_create(parent, callback, x_loc, y_loc, label_length, box_length, @
label, value, label_above, datatype, num_vals)
ui_selectframe_create(parent, callback, x_loc, y_loc, width, height, @
label, recycle)
ui_selectdatabox_create(parent, callback, x_loc, y_loc, label_length, @
box_length, label, value, label_above, datatype, prompt)
ui_separator_create(parent, name, x_loc, y_loc, length, horizontal)
ui_button_create(parent, callback, x_loc, y_loc, width, height, label, @
flag, highlight)
ui_wid_get(widget_id, parameter, value)
ui_wid_get_vstring(widget_id, parameter, value)
NumElms = fem_u_count_id_list(SublistType, PickList, DoMsg, Status)
fem_u_get_id_list(SublistType, PickList, NumElms, DoMsg, ElmIds)
ga_group_exist_get(GroupName, IntegerFlag)
ga_group_create(GroupName)
db_get_elem_etop(NumElms, ElmIds, ElmTops)
db_get_elem_topology_data(NumElms, ElmTops, ElmShapes, NodesPerElm)
ga_group_entity_add(GroupName, ElmList)
Code Example
Script:
#! /bin/sh
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Provides a front-end for external executables and scripts
# in support of MSC/PATRAN PCL.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
case `uname` in
SunOS) Machine=SUN ;;
IRIX*) Machine=SGI ;;
AIX) Machine=IBM ;;
HP-UX) Machine=HP700 ;;
OSF1) Machine=DECA ;;
esac
if [ $# -eq 0 ] ; then
exec $CmdDir/bin/exe/$Machine/$CmdName
else
exec $CmdDir/bin/exe/$Machine/$CmdName "$@"
fi
Locking a database
FUNCTION my_spawn()
INTEGER status
status = db_commit_raw()
utl_display_process_error( status, 3 )
END IF
status = db_start_transaction_raw()
END FUNCTION
FUNCTION my_spawn()
INTEGER status
STRING database_name[256]
status = db_name_get ( database_name )
status = uil_file_close.go()
status = utl_process_spawn ( process arg2, TRUE )
IF ( utl_process_error ( status ) ) THEN
utl_display_process_error( status, 3 )
END IF
status = uil_file_open.go( database_name )
END FUNCTION
File Widget
(filter label)
(filter mask)
(directory label) (files label)
(selection label)
(default selection)
Spreadsheet Widget
Create a form with a file widget for use with your function that
writes nodal data (Exercise 4). Do the same for your function to
read nodal data (Exercise 5).
Extra Credit: Suppose your form with a file widget is a secondary
form, i.e., it is opened from a button on a primary or
main form. Typically, action occurs or a command is
executed when the Apply button on the main form
is pressed. How do you transfer the filename
information from the secondary form to the primary
form?
One way to add help to your PCL is to create your own form
which contains a text widget (ui_text_create).
An easier way is to use the shareware help functions
FUNCTION description_cb()
shareware_help.set_alltext(Aero Preference, @
PURPOSE:\n//@
For comments/remarks, send an email to:\n//@
elvis.mscsoftware.com)
END FUNCTION
Functions
Example
FUNCTION calc_elm_normals(num_elms, elm_ids, normal_vec)
FOR (i = 1 to num_elms)
uil_pcntcomplete.update(i*100.0/num_elms)
END FOR
uil_pcntcomplete.close()
RETURN (0)
General
Functions
Example
FOR (i = 1 to num_elms)
IF (!em_proceed_normal()) THEN RETURN (-1)
END FOR
Graphic Objects
Graphic Segments
Example
INTEGER SegmentId
gm_segment_create(SegmentId)
gm_segment_flush()
Very primitive
MSC.Patran PCL Workshop Notes graphics 05/05/17
132/252
Primitive Graphics
Another Example
FUNCTION Draw2DBox(ColorId, UpperLeft, LowerRight, SegmentId)
/*
Input ColorId INTEGER
UpperLeft(2) REAL
LowerRight(2) REAL
Output SegmentId INTEGER
<return value> INTEGER
*/
BoxCorners(1, 1) = UpperLeft(1)
BoxCorners(1, 2) = LowerRight(2)
BoxCorners(1, 3) = 0.0
BoxCorners(3, 1) = LowerRight(1)
BoxCorners(3, 2) = UpperLeft(2)
BoxCorners(3, 3) = 0.0
status = gm_segment_create(SegmentId)
IF (status != 0) THEN RETURN status
RETURN 0
Be sure to:
1) Use ui_colormenu_create() to allow the user to change
the color of the lines or labels
2) Use a select frame with an Auto Execute toggle
3) Have a Reset Graphics button that calls
gm_segment_delete() to erase the graphics.
You will use the following primitive graphic functions:
a) gm_segment_create()
b) Either gm_draw_line() or gm_draw_text()
c) gm_segment_flush()
d) gm_segment_delete()
Example
CLASS my_pulldown_menu
FUNCTION init()
WIDGET menubar
menubar = uil_primary.get_menubar_id()
FUNCTION display()
/* Dummy display function. The display function is not really necessary
since the menubar is automatically displayed by MSC.Patran. */
END FUNCTION /* display */
SWITCH (item)
CASE (hello_world)
hello_world()
CASE (dump_nodes)
DumpNodes(MyFile.dat)
CASE (push_me)
ui_exec_function(push_me_form, display)
CASE (football)
ui_exec_function(football_scores, display)
CASE (group_by_shape)
ui_exec_function(group_elms_by_shape, display)
END SWITCH
*CLASS = -NA-
*FUNCTION = hello_world Executes a function that is not
*LABEL = Hello World! contained within a PCL Class. The
*LOAD ITEM function cannot have any
arguments.
*SEPARATOR
*CLASS = push_me_form
*FUNCTION = display
*LABEL = Push Me Opens a form via the
*LOAD ITEM ui_exec_function(classname, function) command.
*CLASS = group_elms_by_shape
*FUNCTION = display
*LABEL = Group Elms By Shape
*LOAD ITEM Pulldown menus are designed to
open forms. This is why selecting a
menu item executes:
ui_exec_function()
MSC.Patran PCL Workshop Notes 05/05/17
139/252
MSC.Patran PCL Workshop Notes 05/05/17
140/252
MSC.Patran Customization
FUNCTION toggle_view()
IF (flag) THEN
/* aircraft front view */
rot_x = -90.0
rot_y = 0.0
rot_z = 90.0
ELSE
/* aircraft rhs view */
rot_x = -90.0
rot_y = 0.0
rot_z = 180.0
END IF
flag = !flag
INTEGER i, j, status
INTEGER num_bars, bar_ids()
INTEGER elm_connect(1, 2)
INTEGER rcids(1), acids(1)
REAL bar_len()
REAL xyz(2, 3)
REAL sum
FOR (i = 1 to num_bars)
status = db_get_node_for_elems(1, 2, bar_ids(i:i), elm_connect)
IF (status != 0) THEN RETURN (status)
sum = 0.0
FOR (j = 1 to 3)
sum += (xyz(2, j) xyz(1, j))**2
END FOR
RETURN (0)
END FUNCTION
REAL bar_len()
REAL xyz(VIRTUAL)
REAL sum
sys_allocate_array(elm_connect, 1, num_bars, 1, 2)
sys_allocate_array(node_ids, 1, 2*num_bars)
sys_move_raw(elm_connect, node_ids)
sys_allocate_array(idum, 1, num_nodes)
sys_allocate_array(xyz, 1, num_nodes, 1, 3)
FOR (i = 1 to num_bars)
p1 = mth_array_search(node_ids, elm_connect(i, 1), TRUE)
p2 = mth_array_search(node_ids, elm_connect(i, 2), TRUE)
sum = 0.0
FOR (j = 1 to 3)
sum += (xyz(p2, j) xyz(p1, j))**2
END FOR
RETURN (0)
END FUNCTION
This function gets nodal coordinate frames and coordinates for the
requested nodes.
Input
INTEGER num_nodes Number of nodes to get
information for
INTEGER ARRAY node_ids(num_nodes) Node Ids of nodes to get
information for
Output
INTEGER ARRAY rcids(num_nodes) Reference coordinate frame Ids
INTEGER ARRAY acids(num_nodes) Analysis coordinate frame Ids
REAL ARRAY global_xyz(num_nodes, 3) Global coordinates for each
node
INTEGER <return value> The function returns a value of 0
when executed successfully and
a non-zero value to indicate a
change in status or an error
int num_nodes
int *node_ids
int *rcids
int *acids
float *global_xyz
db_count_nodes(NumNodes)
IF (NumNodes == 0) THEN RETURN 1
sys_allocate_array(NodeIds, 1, NumNodes)
db_get_node_ids(NumNodes, NodeIds)
sys_allocate_array(rcids, 1, NumNodes)
sys_allocate_array(acids, 1, NumNodes)
sys_allocate_array(NodeXYZ, 1, NumNodes, 1, 3)
Node
RC ID RCID
AC ACID X Y Z
2 0 0 0.00 0.00 0.00
5 0 2 5.12 -6.34 4.90
25 1 1 56.20 9.01 -1.10
db_count_elems(NumElms)
sys_allocate_array(ElmIds, 1, NumElms)
sys_allocate_array(ElmTopoCodes, 1, NumElms)
db_get_elem_ids(NumElms, ElmIds)
db_count_elems(NumElms)
sys_allocate_array(ElmIds, 1, NumElms)
sys_allocate_array(ElmTopoCodes, 1, NumElms)
db_get_elem_ids(NumElms, ElmIds)
sys_allocate_array(ElmShapeCodes, 1, NumElms)
sys_allocate_array(NumNodesPerElm, 1, NumElms)
db_count_elems(NumElms)
sys_allocate_array(ElmIds, 1, NumElms)
sys_allocate_array(ElmTopoCodes, 1, NumElms)
sys_allocate_array(ElmShapeCodes, 1, NumElms)
sys_allocate_array(NumNodesPerElm, 1, NumElms)
db_get_elem_ids(NumElms, ElmIds)
db_get_elem_etop(NumElms, ElmIds, ElmTopoCodes)
sys_free_array(ElmTopoCodes)
sys_free_array(ElmShapeCodes)
MaxNodesPerElm = NumNodesPerElm(NumElms)
sys_free_array(NumNodesPerElm)
INTEGER i
INTEGER NumElms, ElmIds()
INTEGER NumRegions, RegionIds(VIRTUAL)
INTEGER MyRegionId
LOGICAL match
STRING MyPropertySetName[]
STRING RegionNames[32](VIRTUAL)
db_count_region_ids(NumRegions)
sys_allocate_array(RegionNames, 1, NumRegions)
sys_allocate_array(RegionIds, 1, NumRegions)
match = FALSE
FOR (i = 1 to NumRegions)
IF (str_equal(MyPropertySetName, RegionNames(i))) THEN
match = TRUE
MyRegionId = RegionIds(i)
BREAK
END IF
END FOR
sys_free_array(RegionIds)
sys_free_array(RegionNames)
db_count_elements_in_region(MyRegionId, NumElms)
sys_allocate_array(ElmIds, 1, NumElms)
RETURN 0
END FUNCTION
INTEGER p
INTEGER ElmId
INTEGER ElmIds(1), ElmRegionIds(1)
INTEGER MaterialId, DataType, IntegerVal, CoordId, NodeId, FieldId
REAL ElmThick, ThickVals(VIRTUAL)
REAL RealVals(3)
STRING CharVal[80]
ElmIds(1) = ElmId
db_get_region_for_elements(1, ElmIds, ElmRegionIds) 36 is the property word Id for
thickness. Other property words
and their associated Ids can be
db_count_prop(ElmRegionIds, NumWords) found listed in the table of generic
property words in Chapter 7 of the
IF (NumWords == 0) THEN RETURN 1 PCL and Customization
documentation.
sys_allocate_array(WordIds, 1, NumWords)
END FUNCTION
There are many other ways to accomplish this same task. The
preceding function is very general and very detailed. If the
element property set references a field for the shell thickness
definition, then functions to evaluate the fields
(MyFunc_EvalScalarFieldCentroid() and
MyFunc_EvalScalarFieldNodes()) will need to be written. If the
shell thickness is only defined at the element centroid, then the
ep_word_val_at_el_cen() function can be used. This function has
an advantage over the previous example in that this function
automatically evaluates any field reference.
ElmIds(1) = ElmId
ElmThick = ThickVals(p)
RETURN 0
END FUNCTION
INTEGER MatlId
REAL ElasticModulus
STRING MatlName[]
db_get_material_id_from_name(MatlName, MatlId)
db_get_matl_prop_value_count(MatlId, NumWords)
sys_allocate_array(WordIds, 1, NumWords)
sys_allocate_array(FieldIds, 1, NumWords)
sys_allocate_array(WordVals, 1, NumWords)
p = mth_array_search(WordIds, 2, FALSE)
IF (p == 0) THEN RETURN 1
2 is the material property
word Id for the Elastic
IF (FieldIds(p) != 0) THEN Modulus. Other material
/* Elastic Modulus is defined property word Ids can be
by a field */ found in the table of Material
ELSE Property Words in Chapter 7
of the PCL and Customization
ElasticModulus = WordVals(p) documentation.
END IF
RETURN 0
END FUNCTION
INTEGER NumGroups
STRING GroupNames[32](VIRTUAL)
ga_group_ngroups_get(NumGroups)
sys_allocate_array(GroupNames, 1, NumGroups)
ga_group_groups_get(Group_names)
INTEGER GroupId
INTEGER NumNodes, NodeIds(VIRTUAL), NumElms, ElmIds(VIRTUAL)
STRING CurrentGroup[32]
ga_group_current_get(CurrentGroup)
db_get_group_id(CurrentGroup, GroupId)
db_count_nodes_in_group(GroupId, NumNodes)
db_count_elems_in_group(GroupId, NumElms)
Resultcase
Result type
Position or layer
Result quantity
Element Ids
Coordinate reference
db_get_load_case_id(lc_name, lc_id)
INPUT: lc_name STRING
OUTPUT: lc_id INTEGER
db_get_primary_res_id(prim_label, prim_id)
INPUT: prim_label STRING
OUTPUT: prim_id INTEGER
res_data_get_result_names(prim_id, sec_id, @
prim_label, sec_label)
INPUT: prim_id INTEGER
sec_id INTEGER
OUTPUT: prim_label STRING
sec_label STRING
res_data_get_result_ids(prim_label, sec_label, @
prim_id, sec_id)
res_utl_get_result_ids(num_rc, lc_ids, sc_ids, @
num_res, prim_ids, sec_ids)
INPUT: num_rc INTEGER
lc_ids INTEGER ARRAY
sc_ids INTEGER ARRAY
OUTPUT: num_res INTEGER
prim_ids INTEGER ARRAY
sec_ids INTEGER ARRAY
res_data_get_layerpos_name(layer_id, layer_name)
INPUT: layer_id INTEGER
OUTPUT: layer_name STRING
res_data_get_layerpos_id(layer_name, layer_id)
INPUT
INTEGER ResIds(5) MSC.Patran internal loadcase ID,
subcase ID, primary result ID,
secondary result ID, and layer ID.
STRING ElmList[] List of elements to extract results
for.
STRING Derivation[10] Derivation specifier if the results
are to be derived, i.e., VONM,
MAJOR, etc. A null value () will
leave the result as is.
STRING Location[] Location at which to extract the
results. Null () or A=as is,
C=element centroid, and
N=element nodes.
STRING CID[] Coordinate system for vector and
tensor transformations. A null
string () is used to leave the
coordinate specification as is.
OUTPUT
INTEGER DataType Datatype for extracted results.
Valid values are: 1=scalar,
2=vector, and 3=tensor. Note that
the Derivation parameter determines
what this value should be, i.e., if
the Derivation is VONM for the
VonMises stress then the DataType
will be 1 for a scalar value.
INTEGER ResLoc Location within the element for the
extracted results. Valid values
are: 1=centroid, 2=nodal, and
Declaration
STRING GroupName[32], Filename[256]
STRING GroupNames[32](VIRTUAL)
STRING Names[80](3)
STRING picklist[VIRTUAL]
Initialization
GroupName = MyGroup
String Comparisons
Functions
str_length(MyString)
DESCRIPTION
Returns the current length of a PCL string.
INPUT
MyString String[] String for which to
return the length.
OUTPUT
<return value> Integer Length of MyString.
EXAMPLE
length = str_length(abcde)
length -> 5
str_strip_trail(MyString)
DESCRIPTION
Return a copy of the string with the trailing spaces
removed.
INPUT
MyString String[] Input string with
trailing spaces.
OUTPUT
<return value> String[] Output string with no
trailing spaces.
EXAMPLE
MyString2 = str_strip_trail( a b c )
MyString2 -> a b c
str_from_integer(ival)
DESCRIPTION
Convert an integer to a string.
INPUT
ival Integer Input integer value.
OUTPUT
<return value> String[] String value.
EXAMPLE
MyString = str_from_integer(12)
MyString -> 12
OTHER FUNCTIONS
str_to_real(MyString[, status])
str_from_real(RealValue)
str_to_logical(MyString)
str_from_logical(LogicalValue)
Noteworthy Functions
sys_move_raw()
sys_move_raw(source, destination)
DESCRIPTION
Move one raw PCL variable to another. This is a great
function to use when transferring the contents of one array
to another array. It is significantly faster than a loop.
INPUT
source Any Source variable to copy.
OUTPUT
destination Any Destination variable to receive
the copy of the source variable.
EXAMPLE
INTEGER a(12), b(12), c(6, 12), d(24)
sys_move_raw(a, b)
sys_move_raw(a, c(1, 1:))
sys_move_raw(a, c(1, 1:12))
sys_move_raw(a(1:), c(1, 1:))
sys_move_raw(a, c(2, 1:12))
sys_move_raw(a, d(1:12))
sys_move_raw(a, d(13:))
mth_array_search()
mth_array_search(IntegerArray, Look4, Sorted)
DESCRIPTION
Search an integer array for a value.
INPUT
IntegerArray Integer array Integer array of values
to search.
Look4 Integer Value to look for within
the IntegerArray
Sorted Logical TRUE if the input array
is sorted. This makes
the search faster.
OUTPUT
<return value> Integer Array index indicating
the position within
IntegerArray where the
Look4 value was found.
Zero if the value was
not found
EXAMPLES
INTEGER p
INTEGER a(4) = [1, 5, 2, 3]
p = mth_array_search(a, 2, FALSE)
p -> 3, i.e., a(3) = 2
p = mth_array_search(a, 12, FALSE)
p -> 0, i.e., a(i) != 12
mth_sort()
mth_sort(Array, RemoveDuplicates, NumLeft)
DESCRIPTION
This function will sort an array of integers into ascending
order, optionally removing all duplicates.
INPUT
Array Integer array Integer array to be
sorted. This argument
is used for both input
and output. The
contents of the
original array are
destroyed and replaced
by the sorted values.
RemoveDuplicates Logical When set to TRUE,
duplicate values are
removed.
OUTPUT
Array Integer array Input array in sorted
order.
NumLeft Integer Number of items in the
sorted array.
EXAMPLE
INTEGER a(4) = [5, 1, 9, 8]
INTEGER NumLeft
mth_sort(a, TRUE, NumLeft)
a(1:4) -> 1, 5, 8, 9
NumLeft -> 4
mth_sort_row()
mth_row_sort(Array, Row, Ascend)
DESCRIPTION
Sorts a two-dimensional integer or real array by one of its
rows.
INPUT
Array Integer or Real Matrix of values to sort.
array This is both the input and
output array.
Row Integer Row Id to sort on.
Ascend Logical If TRUE, then sort in
ascending order.
OUTPUT
Array Integer or Real Matrix is sorted in place.
array
EXAMPLE
INTEGER a(2, 3) = [3, 1, 2, 4, 5, 6]
mth_row_sort(a, 1, TRUE)
a() -> [1, 2, 3, 5, 6, 4]
mth_sort_column()
mth_sort_column(Array, Column, Ascend)
DESCRIPTION
Sorts a two-dimensional integer or real array by one of its
columns.
fem_geom_edge_length()
fem_geom_edge_length(PickList, Lengths, NumLengths)
DESCRIPTION
Determines the length of bar elements and/or element edges.
INPUT
PickList String[] String of bar element Ids
or element edges (elm 1.1).
OUTPUT
Lengths(virtual) Real array Length of each entity in
PickList.
NumLengths Integer Number of entities
contained in PickList.
<return value> Integer Zero for success
fem_geom_face_area()
fem_geom_face_area(PickList, Areas, NumAreas)
DESCRIPTION
Returns the face area of 2D elements or 3D element faces.
fem_geom_elem_volume()
fem_geom_elem_volume(PickList, Volumes, NumVolumes)
DESCRIPTION
Returns the volumes of 3D elements.
fem_geom_elem_location()
fem_geom_elem_location(PickList, Locations, NumLocations)
DESCRIPTION
Returns the location of the centroid of elements, element
edges, etc.
* SPACING
*
*
* Spacing should be done relative to the active font height in system.
* A "single_space" is simply one font height. The "inter_widget_space"
* should be used as the spacing between widgets in a frame. It is
* three quarters of a font height.
*
*
* Spacing variables:
*
* INTER_WIDGET_SPACE - 3/4 of a font height
* INTER_GROUP_SPACE - Twice the size of a "inter_widget_space"
*
* SINGLE_SPACE - A font height in inches
* QTR_SPACE - 1/4 of a font height
* HALF_SPACE - 1/2 of a font height
* THREE_QTR_SPACE - 3/4 of a font height
* ONE_AND_HALF_SPACE - 1.5 times a font height
* DOUBLE_SPACE - 2.0 times a font height
*
* FONT_HGT - Font height in inches
* TEXT_FONT_HGT - Text font height in inches
* SS_FONT_HGT - Spreadsheet font height in inches
*
* LINE_THICKNESS - Thickness of a separator
* FRAME_1EDGE - Thickness of a frame edge
* FRAME_2EDGE - Thickness of both frame edges
* SFRAME_1EDGE - Thickness of a select frame edge
* SFRAME_2EDGE - Thickness of both select frame edges
* SCROLL_FRAME_1EDGE - Thickness of a scroll frame edge
* SCROLL_FRAME_2EDGE - Thickness of both scroll frame edges
* SPREADSHEET_1EDGE - Thickness of a spreadsheet edge
* SPREADSHEET_2EDGE - Thickness of both spreadsheet edges
* HIGHLITE_1EDGE - Thickness of a highlight border around widgets
* HIGHLITE_2EDGE - Thickness of both highlight borders
*
* ICON_HGT - Height of an icon
*
* LOGO_ICON_WID - Width of a logo icon
* LOGO_ICON_HGT - Height of a logo icon
*
* BUTTON_ICON_1EDGE - Thickness of a button icon border
* BUTTON_ICON_2EDGE - Thickness of a both button icon borders
* LABEL_ICON_1EDGE - Thickness of a label icon border
* LABEL_ICON_2EDGE - Thickness of a both label icon borders
* ITEM_ICON_1EDGE - Thickness of a item icon border
* ITEM_ICON_2EDGE - Thickness of a both item icon borders
* TOGGLE_ICON_1EDGE - Thickness of a toggle icon border
* TOGGLE_ICON_2EDGE - Thickness of a both toggle icon borders
*
* COLOR_MENU_WID - Width of a color menu
* COLOR_MENU_HGT - Height of a color menu
* COLOR_MENU_LABEL_Y_OFFSET - Y offset for centering a label next to
* a color menu
MSC.Patran PCL Workshop Notes 05/05/17
196/252
Appendix D
* COLOR_MENU_TOGGLE_Y_OFFSET - Y offset for centering a toggle next to
* a color menu
*
* COLOR_BOX_WID - Width of a color box
* COLOR_BOX_HGT - Height of a color box
* COLOR_BOX_LABEL_Y_OFFSET - Y offset for centering a label next to
* a color box
* COLOR_BOX_TOGGLE_Y_OFFSET - Y offset for centering a toggle next to
* a color box
* COLOR_BAR_WID - Width of a color bar
*
* INCREMENTAL_ICON_WID - Width of an incremental button icon
* INCREMENTAL_ICON_HGT - Height of an incremental button icon
*
*************************************************************************
* FORMS
*
*
* Create an application form. Note that all forms should use the "UL"
* screen position, since the values returned by these variables are
* based on that assumption.
*
* ui_form_create( "", FORM_X_LOC, @
* FORM_Y_LOC, "UL", @
* FORM_WID_SML, @
* FORM_HGT_TALL, "Label", "Icon" )
*
*
* Create a medium width form next to an application form, and don't
* cover the command window. Use the "Full" height form.
*
* ui_form_create( "", FORM_X_LOC_MED_NX2_SML, @
* FORM_Y_LOC, "UL", @
* FORM_WID_MED, @
* FORM_HGT_FULL, "Label", "Icon" )
*
*
* Create a centered, half height, medium width modal form.
*
* ui_modalform_create( "", FORM_X_LOC_MED_CEN, @
* FORM_Y_LOC_HALF_CEN, "UL", @
* FORM_WID_MED, @
* FORM_HGT_HALF, "Label" )
*
*
* Form Placement - X Location:
*
* FORM_X_LOC - Normal form X location
*
* FORM_X_LOC_SML - Normal form X location (same as FORM_X_LOC)
* FORM_X_LOC_SPL - Special form X location (width is 1.5
* times a normal or small form)
* FORM_X_LOC_MED - Medium form (medium width) X location
* FORM_X_LOC_LRG - Large form (large width) X location
*
*************************************************************************
*************************************************************************
* FRAMES
*
*
* Create a frame in an application form. Assume this is the first
*************************************************************************
* SELECT FRAMES
*
*
* Create a select frame in an application form. Put two select databoxes
* in the select frame. Then compute the Y location for the next widget.
* Note the use of the supplied Y locations for the select databoxes as
* well as the height of the select frame.
*
* y_loc = APP_FORM_FIRST_Y_LOC
*
* ui_selectframe_create( form_id, "callback", @
* FORM_L_MARGIN, @
* y_loc, @
* SFRAME_WID_SINGLE, @
* SFRAME_2SDB_HGT_LABOVE, @
* "Select Frame Label", @
* recycle_flag )
*
* ui_selectdatabox_create ( sel_frame_id, "", @
* SFRAME_L_MARGIN, @
* SDBOX_Y_LOC1, 0.0, @
* SDBOX_WID_SINGLE, @
* "Select Databox One", @
* value, TRUE, datatype, @
* prompt )
*
* ui_selectdatabox_create ( sel_frame_id, "", @
* SFRAME_L_MARGIN, @
* SDBOX_Y_LOC2, 0.0, @
* SDBOX_WID_SINGLE, @
* "Select Databox One", @
* value, TRUE, datatype, @
* prompt )
*
* y_loc = y_loc + SFRAME_LABEL_HGT + @
* SFRAME_2SDB_HGT_LABOVE + @
* SFRAME_2EDGE + @
* INTER_WIDGET_SPACE
*
*
* Select Frame Widths and Heights:
*
* SFRAME_WID_SINGLE - Width of a single width select frame
* SFRAME_WID_SPECIAL - Width of a special width select frame
* SFRAME_WID_DOUBLE - Width of a double width select frame
* SFRAME_WID_TRIPLE - Width of a triple width select frame
*
* SFRAME_LABEL_HGT - Height of the label above a select frame
*
* SFRAME_1SDB_HGT_LABOVE - Height of a select frame with
* 1 select databox with a label
* SFRAME_2SDB_HGT_LABOVE - Height of a select frame with
* 2 select databoxes with labels
*************************************************************************
* SCROLL_FRAMES
*
*
* Create a scroll frame in a form.
*
*
* Scroll Frame Widths and Heights:
*
* SCROLL_FRAME_WID_SINGLE - Width of a single width scroll frame
* SCROLL_FRAME_WID_SPECIAL - Width of a special width scroll frame
* SCROLL_FRAME_WID_DOUBLE - Width of a double width scroll frame
* BUTTONS
*
*
* Create two buttons in a small form. The button on the left is a
* default button. Use "half" size buttons.
*
* ui_button_create ( form_id, "callback", @
* BUTTON_HALF_X_LOC1, @
* y_loc, @
* BUTTON_WID_HALF, @
* 0.0, "Left Button", @
* TRUE, TRUE )
*
* y_loc = y_loc + BUTTON_Y_OFFSET
*
* ui_button_create ( form_id, "callback", @
* BUTTON_HALF_X_LOC2, @
* y_loc, @
* BUTTON_WID_HALF, @
* 0.0, "Right Button", @
* TRUE, FALSE )
*
* y_loc = y_loc + BUTTON_Y_OFFSET + @
* BUTTON_HGT + @
* INTER_WIDGET_SPACE
*
*
* Button Widths and Heights:
*
* BUTTON_WID_FULL - Width of a wide button on a small form
* BUTTON_WID_HALF - Width of a medium button on a small form
* BUTTON_WID_THIRD - Width of a small button on a small form
*
* BUTTON_WID_FULL_NT - Width of a non_troughed wide button on
* a small form
* BUTTON_WID_HALF_NT - Width of a non_troughed medium button on
* a small form
* BUTTON_WID_THIRD_NT - Width of a non_troughed small button on
* a small form
*
* BUTTON_HGT - Button height
* BUTTON_DEFAULT_HGT - Default button height (includes top and
* bottom borders)
* BUTTON_HGT_NT - Button height of non_troughed button
*
* BUTTON_DEFAULT_BORDER_WID - Default button border width
* BUTTON_DEFAULT_BORDER_HGT - Default button border height
*
*
* Button Location Offsets:
*
* BUTTON_IN_FRAME_X_OFFSET - X offset for placing buttons inside
* frames using the X Positions defined
* below
*
*************************************************************************
* DATABOXES
*
*
* Create a framed databox with a label above the databox. Then
* compute the Y location for the next widget inside the frame.
*
* y_frame_loc = FRAME_T_MARGIN
*
* ui_databox_create ( frame_id, "", @
* FRAME_L_MARGIN, @
* y_frame_loc, 0.0, @
* DBOX_WID_SINGLE, @
* "Databox Label", value, @
* TRUE, datatype, num_vals )
*
* y_frame_loc = y_frame_loc + @
* DBOX_HGT_LABOVE + @
* INTER_WIDGET_SPACE
*
*
* Create a framed databox with a label to the side. Use the
* default label length for a single column databox and compute
* the databox width.
*
* y_frame_loc = FRAME_T_MARGIN
*
* wid = DBOX_WID_SINGLE - @
* DBOX_LABEL_LEN_SINGLE
*
*
* ui_databox_create ( frame_id, "", @
* FRAME_L_MARGIN, @
* y_frame_loc, @
* DBOX_LABEL_LEN_SINGLE, @
* wid, @
* "Databox Label", value, @
* FALSE, datatype, num_vals )
*
*
* Databox Width and Height:
*
* DBOX_WID_SINGLE - Width of a single width databox
* DBOX_WID_SPECIAL - Width of a special width databox
* DBOX_WID_DOUBLE - Width of a double width databox
* DBOX_WID_TRIPLE - Width of a triple width databox
*
* DBOX_HGT_LABOVE - Height of a databox with a label on the top
* (even if the label is blank)
*************************************************************************
* FILES
*
*
* Create a form centered under the main menu that has a file
* widget inside the a frame. The file widget is placed at
* ( 0.0, 0.0 ) inside the frame (a top margin is not needed).
* The height of the file widget includes a bottom margin
* and therefore can be used as the height of the frame that
* contains the file widget. The file widget has 5 lines in
* the list boxes.
*
* form_hgt = FILE_5L_HGT + FORM_2V_MARGIN + FRAME_2EDGE
* x_loc = WINDOW_CEN_X_LOC - 0.5 * ( wid + FORM_2H_BORDER )
* y_loc = WINDOW_CEN_Y_LOC - 0.5 * ( form_hgt + FORM_2V_BORDER )
*
* form_id = ui_form_create( "", x_loc, y_loc, "UL", @
* wid, form_hgt, @
* "Form Label", "" )
*
* frame_id = ui_frame_create( form_id, "", @
* FORM_L_MARGIN, @
* FORM_T_MARGIN, @
* FRAME_WID_SPECIAL, @
* FILE_5L_HGT, "" )
*
* file_id = ui_file_create( frame_id, "", @
* 0.0, 0.0, @
* FILE_WID_SPECIAL, 5, @
* "Filter Label", @
* "Filter Mask", @
* "Files Label", @
* "Directory Label", @
* "Files Label", @
* "Selection Label", @
* "Default Selection", @
* "Left Button Label", @
* "Right Button Label" )
*
*
* File Width:
*
* FILE_WID_SINGLE - Width of a single width file widget
*************************************************************************
*************************************************************************
* LISTBOXES
*
*
*************************************************************************
* OPTION MENUS
*
*************************************************************************
* SELECT DATABOXES
*
*
* Create a framed select databox with a label above the select databox.
* Then compute the Y location for the next widget.
*
* y_sframe_loc = SFRAME_T_MARGIN
*
* ui_selectdatabox_create ( sel_frame_id, "", @
* SFRAME_L_MARGIN, @
* y_sframe_loc, 0.0, @
* SDBOX_WID_SINGLE, @
* "Select Databox Label", @
* value, TRUE, datatype, @
* prompt )
*
* y_sframe_loc = y_sframe_loc + @
* SDBOX_HGT_LABOVE + @
* INTER_WIDGET_SPACE
*
*
* Create a framed select databox with a label to the side. Use the
* default label length for a single column select databox and compute
* the select databox width.
*************************************************************************
* SLIDEBARS
*
*
* Create a slidebar inside a frame and then compute the y location
* of the next widget inside the frame. The slidebar has a label
* as well as min/max labels above the displayed values.
*
* y_frame_loc = FRAME_T_MARGIN
*
* ui_slidebar_create ( frame_id, "callback", @
* FRAME_L_MARGIN, @
* y_frame_loc, @
* SLIDER_WID_SINGLE, @
* "Slidebar Label", value, @
* num_digits, TRUE, "Min", "Max", @
* TRUE, 0, 10 ) @
*
* y_frame_loc = y_frame_loc + @
* SLIDER_HGT_COMPLETE + @
* INTER_WIDGET_SPACE
*
*
* Sliderbar Width and Height:
*
* SLIDER_WID_SINGLE - Width of a single width slidebar
* SLIDER_WID_SPECIAL - Width of a special width slidebar
* SLIDER_WID_DOUBLE - Width of a double width slidebar
* SLIDER_WID_TRIPLE - Width of a triple width slidebar
*
* SLIDER_HGT_COMPLETE - Height of slidebar with min/max labels,
* the values shown and a label below the
* slidebar
* SLIDER_HGT_MINMAX - Height of slidebar with min/max labels only
* SLIDER_HGT_VALUES - Height of slidebar with values only
* SLIDER_HGT_LABEL - Height of slidebar with label only (values
* not shown and no min/max labels)
* SLIDER_HGT_MINMAX_VALUES - Height of slidebar with min/max labels and
* values shown (no label)
*************************************************************************
* SPREADSHEETS
*
*
* Create a spreadsheet in a form.
*
*
* Spreadsheet Widths and Heights:
*
* SPREADSHEET_WID_SINGLE - Width of a single width select frame
* SPREADSHEET_WID_SPECIAL - Width of a special width select frame
* SPREADSHEET_WID_DOUBLE - Width of a double width select frame
* SPREADSHEET_WID_TRIPLE - Width of a triple width select frame
*
* SPREADSHEET_LABEL_HGT - Height of the spreadsheet label (to be
* subtracted from the following heights
* in the case that a label is NOT used)
*
* SPREADSHEET_HGT_2D_1ROW - Height of a 2D spreadsheet with 1 row
* SPREADSHEET_HGT_2D_2ROW - Height of a 2D spreadsheet with 2 rows
* SPREADSHEET_HGT_2D_3ROW - Height of a 2D spreadsheet with 3 rows
* SPREADSHEET_HGT_2D_4ROW - Height of a 2D spreadsheet with 4 rows
* SPREADSHEET_HGT_2D_5ROW - Height of a 2D spreadsheet with 5 rows
* SPREADSHEET_HGT_2D_6ROW - Height of a 2D spreadsheet with 6 rows
* SPREADSHEET_HGT_2D_7ROW - Height of a 2D spreadsheet with 7 rows
* SPREADSHEET_HGT_2D_8ROW - Height of a 2D spreadsheet with 8 rows
* SPREADSHEET_HGT_2D_9ROW - Height of a 2D spreadsheet with 9 rows
* SPREADSHEET_HGT_2D_10ROW - Height of a 2D spreadsheet with 10 rows
* SPREADSHEET_HGT_2D_INCR - Height increment for 2D spreadsheet
*
* SPREADSHEET_HGT_3D_1ROW - Height of a 3D spreadsheet with 1 row
* SPREADSHEET_HGT_3D_2ROW - Height of a 3D spreadsheet with 2 rows
* SPREADSHEET_HGT_3D_3ROW - Height of a 3D spreadsheet with 3 rows
* SPREADSHEET_HGT_3D_4ROW - Height of a 3D spreadsheet with 4 rows
* SPREADSHEET_HGT_3D_5ROW - Height of a 3D spreadsheet with 5 rows
* SPREADSHEET_HGT_3D_6ROW - Height of a 3D spreadsheet with 6 rows
* SPREADSHEET_HGT_3D_7ROW - Height of a 3D spreadsheet with 7 rows
*************************************************************************
* SWITCHES
*
*
* Create a framed two row switch with a label. Note that the
* number of rows is a function of the "num_cols" variable and the
* number of items created for the switch.
*
* y_frame_loc = FRAME_T_MARGIN
*
* ui_switch_create( frame_id, "callback", @
* FRAME_L_MARGIN, @
* y_frame_loc, @
* num_cols, "Switch Label", @
* alwaysone_flag )
*
* y_frame_loc = y_frame_loc + @
* SWITCH_2R_HGT_LABEL + @
* INTER_WIDGET_SPACE
*
*
* Switch Height:
*
*
* SWITCH_1R_HGT_LABEL - Height of a 1 row switch with a label
* SWITCH_2R_HGT_LABEL - Height of a 2 row switch with a label
* SWITCH_3R_HGT_LABEL - Height of a 3 row switch with a label
* SWITCH_4R_HGT_LABEL - Height of a 4 row switch with a label
*
* SWITCH_HGT_LABEL_INCR - Increment for creating a switch height with
* more than 4 rows in it
*
* SWITCH_1R_HGT_NO_LABEL - Height of a 1 row switch with no label
* SWITCH_2R_HGT_NO_LABEL - Height of a 2 row switch with no label
* SWITCH_3R_HGT_NO_LABEL - Height of a 3 row switch with no label
* SWITCH_4R_HGT_NO_LABEL - Height of a 4 row switch with no label
*
* SWITCH_HGT_NO_LABEL_INCR - Increment for creating a switch height with
* more than 4 rows in it
*
*************************************************************************
* TEXTBOXES
*
*
* Create a framed three line textbox with a label. Note that the
* widths and heights include the vertical and horizontal sliders.
*
*************************************************************************
* TOGGLES
*
*
* Create a toggle inside a frame and then compute the y location
* of the next widget in the frame.
*
* y_frame_loc = FRAME_T_MARGIN
*
* ui_toggle_create ( frame_id, "callback", @
* FRAME_L_MARGIN, @
*************************************************************************
* LANGUAGE
*
*
* Language variables:
*
* ENGLISH - "English"
* GERMAN - "German"
* SPANISH - "Spanish"
* FRENCH - "French"
* KANJI - "Kanji"
*
* LANGUAGE - Current language (see above)
* HANDEDNESS - Determines whether forms appear on right of left side
* of screen
*
*************************************************************************
* SCREEN
*
*
* Screen variables:
*
* PIXEL_WID - Width of a pixel (in inches)
* PIXEL_HGT - Height of a pixel (in inches)
*
* SCREEN_WID - Width of logical screen (in inches)
* SCREEN_HGT - Height of logical screen (in inches)
*
*************************************************************************
* BASIC LAYOUT
*
*
* Basic layout variables:
*
* MAIN_MENU_X_LOC - Main menu X location
MSC.Patran Architecture
bv_pcl.compile(file_name, plb_name)
DESCRIPTION
Same as !!COMPILE file_name plb_name except that the
file_name is passed through the C-preprocessor (cpp) prior
to compiling. Thus, by using this function you do not need
to use make and a makefile prior to compiling. Note
that if the PCL library does not exist, it is created.
INPUT
file_name String[] File containing PCL to
be compiled
plb_name String[] Name of PCL library
file.
OUTPUT
<None>
EXAMPLE
bv_pcl.compile(My_very_own_pcl.pcl, My_pcl_library.plb)
bv_pcl.compile_all(plb_name)
DESCRIPTION
Same as bv_pcl.compile() except that all files with a
.pcl extension in the current directory/folder are
compiled. Note that special MSC.Patran files such as
settings.pcl or p3epilog.pcl are not compiled.
INPUT
plb_name String[] Name of PCL library
file.
OUTPUT
<None>
EXAMPLE
bv_pcl.compile_all(My_pcl_library.plb)
au_make_all()
DESCRIPTION
Same as bv_pcl.compile_all() except the PCL library
filename is specified via a file called au_makefile.dat
instead of as a function argument. The au_makefile.dat
file contains a single line which is the name of the PCL
library file, i.e., NT_break_elms.plb
INPUT
<None>
OUTPUT
<None>
EXAMPLE
au_make_all()
MSC.Patran PCL Workshop Notes 05/05/17
225/252
Appendix G
Parametric Patran
Output definition
An analysis response or result
Notes
Parametric parameters are saved with the database
A configuration file can be used to supply new parameter
values. This allows automation, i.e., a driving program
could execute MSC.Patran batch jobs with different
configuration files to generate several model variations
automatically
Configuration file can be selected via:
An environment variable:
PARAMETRIC_MODELING_CONFIG_FILE
The first lp_ function used is the lp_eval function. The lp_eval
command:
#define LP_SUBLIST_GEOMETRY \
(LP_SUBLIST_POINT_IMMEDIATE+LP_SUBLIST_VECTOR_IMMEDIATE+\
LP_SUBLIST_POINT+LP_SUBLIST_CURVE+LP_SUBLIST_SURFACE+\
LP_SUBLIST_SOLID+LP_SUBLIST_PLANE+LP_SUBLIST_VECTOR+\
LP_SUBLIST_PLANE_IMMEDIATE)
#define LP_SUBLIST_COORD_FRAME
#define LP_SUBLIST_VECTOR
#define LP_SUBLIST_AXIS
#define LP_SUBLIST_NODE
#define LP_SUBLIST_ELEMENT
#define LP_SUBLIST_MPC
#define LP_SUBLIST_FINITE_ELEMENT \
(LP_SUBLIST_NODE+LP_SUBLIST_ELEMENT+LP_SUBLIST_MPC)
#define LP_SUBLIST_PLANE
#define LP_SUBLIST_ANY
lp_sublist_next()
Attribute Examples
SubList Attribute Definition
Point Sublist Eval: LP_EVAL_FOR_GEOMETRY
Label 2 LP_ATTRIBUTE_LABEL
Id 2 LP_ATTRIBUTE_ID
GeometryInNativeForm [0. 0. 0. 0. 1. 0.] LP_ATTRIBUTE_GEOMETRY_IN_NATIVE_FORM
GeometryType CartesianPoint LP_ATTRIBUTE_GEOMETRY_TYPE
GeometryCompanyOfOrigin PATRAN LP_ATTRIBUTE_GEOMETRY_COMPANY_OF_ORIGIN
EvaluatedPoint [0.0 1.0 0.0] LP_ATTRIBUTE_EVALUATED_POINT
Code example
lp_sublist_attribute_get_int(handle,LP_ATTRIBUTE_LABEL,id)
Returns the label of the current item based on anchor position
lp_sublist_attribute_get_floata(handle_fem,
LP_ATTRIBUTE_LOCATION,BYTES_PER_REAL*3,xyz,size)
Returns Node or Point coordinates as a real array
lp_sublist_attribute_get_inta(handle_fem,
LP_ATTRIBUTE_NODE_LIST,BYTES_PER_INTEGER*cnt(1),nodes,size)
Returns an integer array of nodes associated to an element.
/*
* This function returns the node labels and count
* from the picklist of a select databox.
*
* INPUT: select databox widget ID
*
* OUTPUT: node_labels INTEGER ARRAY Node labels
* num_nodes INTEGER Number of nodes found
*
* This function is the equivalent of fem_u_extract_nodes_ids
*
* Equivalent procedure:
*
* ui_wid_get(sdbox,"VALUE",picklist)
* num_nodes = fem_u_count_id_list(LP_SUBLIST_NODE,picklist,TRUE)
* sys_allocate_array(node_labels,1,num_nodes)
* fem_u_extract_node_ids(picklist,num_nodes,node_labels)
*
*/
#include "lpenums.p"
WIDGET sdbox_id
INTEGER num_nodes, node_labels()
INTEGER i, status
INTEGER list_type, handle, id(1), ints(2)
INTEGER node_ids(VIRTUAL)
LOGICAL end_of_list = FALSE
REAL reals(2)
STRING picklist[VIRTUAL], str[10](2)
$ This line evaluates the pick list for labels and returns a handle
lp_eval(picklist, LP_EVAL_FOR_LABEL, handle)
i += 1
node_ids(i) = id
END IF
IF (status != 0 ) then
end_of_list = TRUE
END IF
UNTIL(i == num_nodes || end_of_list)
write(node_ids)
END FUNCTION
Example
Picklist:"Elm 1 4 Point 55 56 Node 34 36"
Elm 1 4 Point 55 56 Node 34
1 2 3
4
lp_eval(picklist,LP_EVAL_LABEL,handle)
Evaluate the Picklist for Labels
l lp Anchor Points to Element 1
lp_sublist_next(handle)
2 lp Anchor Points to Element 4
lp_sublist_next(handle)
3 lp Anchor Points to Geometric Point 55
lp_sublist_reset(handle)
Resets to beginning of picklist
4 lp Anchor Points to element 1
lp_eval_cleanup(handle)
Terminates parsing for handle
Example
#include lpenums.p
INTEGER status
INTEGER num_elms, elm_ids()
STRING picklist[]
num_elms = FEM_U_COUNT_ID_LIST(LP_SUBLIST_ELEMENT, @
picklist, FALSE, status)
IF (num_elms == 0) THEN
UI_WRITE(No elements selected!); RETURN (-1)
END IF
SYS_ALLOCATE_ARRAY(elm_ids, 1, num_elms)
RETURN (status)
END FUNCTION
Key Mapping
Widget Classification
CLASS my_class
CLASSWIDE WIDGET main_form, my_opt_menu
FUNCTION init()
my_opt_menu = ui_optionmenu_create(main_form, @
my_opt_menu_cb, x_loc, y_loc, 0, @
Action:, TRUE)
ui_item_create(my_opt_menu, C, Create, FALSE)
ui_item_create(my_opt_menu, E, Edit, FALSE)
ui_item_create(my_opt_menu, D, Delete, FALSE)
$ ui_item_create(parent, name, label, toggleable)
END FUNCTION
FUNCTION my_opt_menu_cb(value)
STRING value[]
SWITCH (value)
case (C)
/* display create options */
case (E)
/* display edit options */
case (D)
/* display delete options */
END SWITCH
END FUNCTION
END CLASS