Msc. Patran pcl handbook In a Nutshell 7



Download 1.08 Mb.
Page25/25
Date05.08.2017
Size1.08 Mb.
#26706
1   ...   17   18   19   20   21   22   23   24   25

Appendix H

Additional List Processor Notes





List Processor Mechanics


  • The List Processor evaluates or parses a Picklist for information that the application needs.

  • The Picklist is retrieved from the specified Select Databox using the ui_wid_get_vstring() command. This command automatically sizes a virtual string to store the picklist data.

  • The low level, more flexible List Processor functions begin with the prefix, lp_. In addition to these functions, there are other more "user friendly" functions which perform more specific tasks.

  • The “user friendly” functions also offer another benefit. Most lp_ functions make calls to the database to obtain information about the Picklist. The more user-friendly functions, such as the fem_u_ functions, only evaluate for ids and do not require querying the database. This gives the benefit of improved performance.

  • When using the List Processor functions it is necessary to #include the lpenums.p file with the C Preprocessor (cpp). This file contains all the keywords used to define the evaluation methods for interpreting the Picklist with the various List Processor functions.

  • A Picklist may be comprised of one or more sublists. Each sublist in a Picklist has a type and attributes associated to it.

If a user is selecting nodes and elements, each of the entity types would comprise a sublist. The Picklist, “Node 1 2 45 Element 2 4 6” contains two sublists based on use of the lp_sublist_node and lp_sublist_element sublist filters.

List Processor Functions


  • The first lp_ function used is the lp_eval function. The lp_eval command:

  • Evaluates the Picklist using a filter method, (lpenums.i)

A Picklist is evaluated for specific information. If a Picklist is evaluated for GEOMETRY, then all FEM entities are skipped over.

  • Establishes an anchor or reference point in the Picklist

  • Returns a handle for identification of the Picklist.

The handle is used in all other lp_ functions.

  • Most common evaluation filters are:

LP_EVAL_FOR_ID
LP_EVAL_FOR _LABEL
LP_EVAL_FOR_GEOMETRY
LP_EVAL_FOR _FEM_DEFINITION




List Processor Sublist Functions


  • lp_sublist functions evaluate the Picklist for type and count information, and moves the list pointer (Anchor) to the next position.

lp_sublist_count(picklist, LP_SUBLIST_POINT, count) /* Count Points in List */

lp_sublist_ Function

Use

lp_sublist_type()

To get the current sublist type being referenced.

lp_sublist_count()

Counts the number of items in a given sublist based on the sublist filter.

(The return count for LP_SUBLIST_POINT includes finite element nodes and geometric points)

l
/* lpenums.i SublistType filters for LpSublistType */

#define LP_SUBLIST_POINT_IMMEDIATE

#define LP_SUBLIST_VECTOR_IMMEDIATE

#define LP_SUBLIST_POINT

#define LP_SUBLIST_CURVE

#define LP_SUBLIST_SURFACE

#define LP_SUBLIST_SOLID
#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



p_sublist_next()


Set the list anchor position to the next sublist.



List Processor Attribute Functions


  • lp_sublist_attribute_ functions evaluate the Picklist based on a sublist attribute filter.

lp attribute Functions

Use

lp_sublist_attribute_get_int()

Return an integer value from a Picklist with a specified attribute.

lp_sublist_attribute_get_float()

Return a real value of integer values from a Picklist with a specified attribute.

lp_sublist_attribute_get_string()

Return a string from a Picklist with a specified attribute.

lp_sublist_attribute_get_inta()

Return an array of integers from a Picklist with a specified attribute.

lp_sublist_attribute_get_floata()

Return a real array from a Picklist with a specified attribute.


/* lpenum.i Attribute names for LpSublistAttributeGet */

#define LP_ATTRIBUTE_ID

#define LP_ATTRIBUTE_LABEL

#define LP_ATTRIBUTE_GEOMETRY

#define LP_ATTRIBUTE_GEOMETRY_TYPE

#define LP_ATTRIBUTE_GEOMETRY_FORMAT

#define LP_ATTRIBUTE_GEOMETRY_COMPANY_OF_ORIGIN

#define LP_ATTRIBUTE_ORIGIN

#define LP_ATTRIBUTE_ROTATION_MATRIX

#define LP_ATTRIBUTE_COORDINATE_FRAME_TYPE

#define LP_ATTRIBUTE_LOCATION

#define LP_ATTRIBUTE_DISPLACEMENT

#define LP_ATTRIBUTE_BASE

#define LP_ATTRIBUTE_TIP

#define LP_ATTRIBUTE_CLASS_NAME

#define LP_ATTRIBUTE_TOPOLOGY_ID

#define LP_ATTRIBUTE_DIMENSIONALITY

#define LP_ATTRIBUTE_FACE_NUMBER

#define LP_ATTRIBUTE_EDGE_NUMBER

#define LP_ATTRIBUTE_VERTEX_NUMBER

#define LP_ATTRIBUTE_NODE_COUNT

#define LP_ATTRIBUTE_NODE_LIST

#define LP_ATTRIBUTE_ORIGINAL_PARSE_CLASS



#define LP_ATTRIBUTE_ORIGINAL_PARSE_SUBCLASS

#define LP_ATTRIBUTE_ORIGINAL_PARSE_SUBCLASS_ID #define LP_ATTRIBUTE_GEOMETRY_IN_NATIVE_FORM

#define LP_ATTRIBUTE_U_VALUE

#define LP_ATTRIBUTE_V_VALUE

#define LP_ATTRIBUTE_TOKEN_VALUE

#define LP_ATTRIBUTE_EVALUATED_POINT

#define LP_ATTRIBUTE_POINT_COUNT

#define LP_ATTRIBUTE_CURVE_COUNT

#define LP_ATTRIBUTE_SURFACE_COUNT

#define LP_ATTRIBUTE_SOLID_COUNT

#define LP_ATTRIBUTE_POINT_LIST

#define LP_ATTRIBUTE_CURVE_LIST

#define LP_ATTRIBUTE_SURFACE_LIST

#define LP_ATTRIBUTE_SOLID_LIST

#define LP_ATTRIBUTE_SIDE_NUMBER

#define LP_ATTRIBUTE_NORMAL

#define LP_ATTRIBUTE_PLANE_COUNT

#define LP_ATTRIBUTE_PLANE_LIST

#define LP_ATTRIBUTE_VECTOR_COUNT

#define LP_ATTRIBUTE_VECTOR_LIST




#define LP_ATTRIBUTE_ORIGINAL_PARSE_SUBCLASS_TOPOLOGICAL_CONTEXT





Miscellaneous List Processor Functions


  • Other List Processor functions.

Functions

Use

lp_print_list()

Print the entire Picklist from the anchor block to standard out. Prints to stdout.

lp_print_sublist()

Print the sublist prepared by lp_sublist_type from the anchor block to standard out. Good for determining the attributes associated with a sublist item.

lp_eval_cleanup()

Frees allocated memory for list processor operations. This should be performed after lp_ operations are complete

lp_sublist_reset()

Reset the sublist parser to resume parsing the original Picklist.

fem_u_count_id_list()

Quick function to count the entities of a specified list processor sublist type without having to use all the other lp_ commands.

fem_u_extract_node_ids()

Quick function to extract the array of nodes IDs from a Picklist.

fem_u_get_id_list()

Quick function to return the entities ids of a specified list processor sublist type without having to use all the other lp_ commands.

app_count_id_list()

Count the entities of a specified list processor type in a list using the picklist decoder routines.



List Processor Examples

Sublist Evaluation for Attributes


  • Attributes may be extracted from an item in a sublist.

  • Attribute information varies based on the sublist type
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







Element

Sublist Eval: LP_EVAL_FOR_FEM_DEFINITION

Id 50

LP_ATTRIBUTE_LABEL

ClassName Bar2

LP_ATTRIBUTE_CLASS_NAME

TopologyId 2

LP_ATTRIBUTE_TOPOLOGY_ID

Dimensionality 1

LP_ATTRIBUTE_DIMENSIONALITY

NodeCount 2

LP_ATTRIBUTE_NODE_COUNT

NodeList [58 57]

LP_ATTRIBUTE_NODE_LIST







Node

Sublist Eval: LP_EVAL_FOR_FEM_DEFINITION

Id 12

LP_ATTRIBUTE_LABEL

Location [0.428571 0.142857 0.000000]

LP_ATTRIBUTE_LOCATION








C
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.



ode example


List Processor PCL Function


Sample PCL, retrieving a list of node labels and the count from a select databox.
FUNCTION get_n_ids(sdbox_wid, num_nodes, node_labels)
/*

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

ui_wid_get_vstring(sdbox_wid, ”VALUE”, picklist)
$ This line evaluates the pick list for labels and returns a handle

lp_eval(picklist, LP_EVAL_FOR_LABEL, handle)


$ Count the number of items of type node.

lp_sublist_count(handle, LP_SUBLIST_NODE, num_nodes)


IF (num_nodes > 0) THEN

sys_allocate_array(node_ids, 1, num_nodes)

write("Node count = "//str_from_integer(num_nodes))

ELSE


RETURN –1 /* Zero nodes found, exit function */

END IF

i = 0

REPEAT


/* Retrieve the sublist type */

status = lp_sublist_type(handle, LP_SUBLIST_ANY, list_type)


/* Print the sublist */

lp_print_sublist(handle)


IF(list_type == LP_SUBLIST_NODE) THEN
status = lp_sublist_attribute_get_int(handle, LP_ATTRIBUTE_LABEL, id)
IF(status != 0 ) THEN /* If error, print the error message and exit */

msg_to_form(status, 3, 0, ints, reals, str)

RETURN (-1)

END IF
i += 1

node_ids(i) = id

END IF
/* Get the next node */

status = lp_sublist_next(handle)
IF (status != 0 ) then

end_of_list = TRUE

END IF

UNTIL(i == num_nodes || end_of_list)


write(node_ids)
/* Set return variables to captured values */

sys_allocate_array(node_labels, 1, num_nodes)



sys_move_raw(node_ids, node_labels)
RETURN 0 /* Return zero for success */
END FUNCTION

List Processor Example, Pointer, (Anchor) Mechanics


  • The lp_sublist_next() command moves the list pointer to the next item in the list.

The evaluation filter used with the lp_eval has no effect on the lp_sublist_next() command. The next item in the list is always the next pointer position.
Example

P
icklist: "Elm 1 4 Point 55 56 Node 34 36"


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

Easy to Use List Processor Functions


  • The fem_u_count_id_list(…) function can be used to count the number of entities in a sublist.

num_ids = fem_u_count_id_list(sublist_type, picklist, @
do_message, status)


  • The fem_u_get_id_list(…) function can be used to extract the entity ids from the picklist based on the sublist type.

fem_u_get_id_list(sublist_type, picklist, num_ids, @
do_message, ids)


  • Example

#include “lpenums.p”
FUNCTION get_selected_elms(picklist, num_elms, elm_ids)
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)
status = FEM_U_GET_ID_LIST(LP_SUBLIST_ELEMENT, picklist, @

num_elms, FALSE, elm_ids)
RETURN (status)
END FUNCTION

Appendix I

Key Mapping







  • Key mapping is defined in a file named .Patran.EventMaps (UNIX) or just Patran.EventMaps (PC)

  • MSC.Patran searches for this file 1st in the current directory/folder, then in the user’s home directory/folder, and finally in the MSC.Patran home directory/folder.

  • A sample Patran.EventMaps file

NoneF2: MouseRotateXY()

NoneF3: MouseRotateZ()

NoneF4: MousePanXY()

NoneF5: MouseZoom()

NoneF6: SelectCorners()

NoneF8: SelectCenter()

NoneF9: FitView()

Nonex: PanRight()

Shiftx: PanLeft()

Noney: PanUp()

Shifty: PanDown()

Nonez: ZoomIn()

Shiftz: ZoomOut()

Ctrlx: RotPosX()

Altx: RotNegX()

Ctrly: RotPosY()

Alty: RotNegY()

Ctrlz: RotNegZ()

Altz: RotPosZ()

Nonel: LabelsOn()

Shiftl: LabelsOff()

Ctrls: SpectrumOnOff()



osfUp:PanUp()

osfDown:PanDown()

osfLeft:PanLeft()

osfRight:PanRight()

None1: RearView()

None2: BottomView()

None3: Iso1View()

None4: LeftSideView()

None5: Iso2View()

None6: RightSideView()

None7: FrontView()

None8: TopView()

None9: Iso3View()



  • Key modifiers can be either None, Ctrl, Alt, or Shift

  • The functions are pre-defined, i.e., TopView(), FrontView(), etc. Custom functions can be access via the CallPCL(…) function, i.e.,

Nonea: CallPCL(“my_function”)

Appendix J

Widget Classification







  • Widgets can be loosely classified into several categories

  • Those that register events (i.e., databoxes, buttons) and those that don’t (i.e., frames, forms). Essentially those widgets that register events will have a callback functions. Those that don’t register events don’t have callback functions.

  • Simple widgets (i.e., toggles, buttons, databoxes) and compound widgets (i.e., option menus, listboxes, switches)

  • Simple widgets are widgets that require only a single function call to create. Examples include:

  • Buttons

  • Databoxes

  • Toggles

  • Compound widgets are widgets that require multiple function calls to create. Generally the initial function call creates a menu into which options or items are placed. In this sense the initial call creates a “placeholder” and the additional function calls add “items.” Examples include:

  • Optionmenus. The function ui_optionmenu_create(…) creates the option menu while multiple calls to ui_item_create(…) adds the menu items.

  • Switches

  • Listboxes

  • Of note is that the “value” of the compound widget that is passed to the widget’s callback function or extracted with ui_wid_get(…) is “name” argument specified on the ui_item_create(…) function call.

  • Example (excerpted, abbreviated)

    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


Appendix K

User Defined AOM







Download 1.08 Mb.

Share with your friends:
1   ...   17   18   19   20   21   22   23   24   25




The database is protected by copyright ©ininet.org 2024
send message

    Main page