Msc. Patran pcl handbook In a Nutshell 7



Download 1.08 Mb.
Page16/25
Date05.08.2017
Size1.08 Mb.
#26706
1   ...   12   13   14   15   16   17   18   19   ...   25

Special Widgets


A number of specialized widgets exist in MSC.Patran. These widgets are for often-used operations or to perform specialized tasks. Two such widgets are the File widget and the Spreadsheet widget.

F
ile Widget


  • The file widget is used whenever a system filename is needed for importing or exporting data.

  • The File widget is built up of many standard widgets and allows for customization of databox labels, listbox labels and file type filtering.

Special Widgets

  • T
    file_widget=ui_file_create( @
    /* parent */ form_id, @
    /* callback */ "file_cb", @
    /* x */ FORM_L_MARGIN, @
    /* y */ FORM_T_MARGIN, @
    /* width */ FILE_WID_DOUBLE, @
    /* rows */ 6, @
    /*
    filterlabel */ "Filter", @
    /*
    filter mask */ "*.db", @
    /*
    Dir label */ "Directories", @
    /*
    files label */ "Database List", @
    /*
    Select label*/ "Existing Database Name",@
    /* Selection */ "", @
    /* OK label */ "OK", @
    /* filt btn lab*/ "Filter", @
    /* Cancel label*/ "Cancel")



    Note: The height of a file widget with 6 rows (lines) is FILE_6L_HGT.
    he headers and filter labels are customizable allowing for adaptation to the specific file type.

Special Widgets

  • The File widget callback function is executed when the Ok/Apply or Cancel button is selected.

T
Sample File Widget callback function
FUNCTION file_cb(filename, file_status)

STRING filename[], file_status[]
IF (file_status == "CANCEL") THEN

ui_form_hide("file_widgets_class") /* close the form */

RETURN

ELSE

/* Send the filename back to the calling function */

Calling_Class.put_filename(filename)

END IF

ui_form_hide("file_widgets_class")

END FUNCTION

he callback sends two string arguments, filename and status. If the Ok/Apply button is selected then any text in the filename databox is sent as a string and the status will be set to "OPEN". If the Cancel button is selected then the status is set to "CANCEL".

Special Widgets


Spreadsheet Widget


  • The Spreadsheet widget was developed by MSC.Software for use in MSC.Patran. The spreadsheet widget can be used for displaying or entering data.

  • The spreadsheet widget performs a callback when a cell or group of cells is selected. The starting and ending columns and rows, and the layer if 3 dimensional, are returned as callback function arguments.

  • To enter data into a spreadsheet, you will need to create a databox.

  • Use the ui_spread_set_cell(s) functions to set the cells of a particular spreadsheet.





Exercise 11: File 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?







Adding Help/Description to your PCL


  • 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



    Or, to read the help text from a file, use:



    shareware_help.set_allinfile(“Aero Preference”, “aero_help.txt”)

Percent Complete

Functions


  • MSC.Patran provides PCL functions to allow the user to create, update, and manage the percent complete form.

  • uil_pcntcomplete.initlz(…) is used to initialize the percent complete form.

  • uil_pcntcomplete.update(…) is used to update the percent complete form

  • uil_pcntcompete.close(…) is used to close the form. Don’t forget to close the form!

Example


FUNCTION calc_elm_normals(num_elms, elm_ids, normal_vec)

INTEGER i, num_elms, elm_ids()

REAL normal_vec()

STRING msg[80]

msg = “Processing “//str_from_integer(num_elms)//” elements …”

uil_pcntcomplete.initlz(msg)

FOR (i = 1 to num_elms)

/* functions that calculate element normals */

uil_pcntcomplete.update(i*100.0/num_elms)

END FOR


uil_pcntcomplete.close()

RETURN (0)

END FUNCTION /* calc_elm_normals */



Download 1.08 Mb.

Share with your friends:
1   ...   12   13   14   15   16   17   18   19   ...   25




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

    Main page