Msc. Patran pcl handbook In a Nutshell 7


PCL for the More Adventurous



Download 1.08 Mb.
Page3/25
Date05.08.2017
Size1.08 Mb.
#26706
1   2   3   4   5   6   7   8   9   ...   25

PCL for the More Adventurous

Parametric Modeling


  • Session files can be parameterized by defining and using variables during the MSC.Patran session

  • F
    irst, variables are declared and initialized via the MSC.Patran command line

PCL for the more Adventurous

  • Second, the variables are used as input into the appropriate MSC.Patran forms (note the use of ` `, back tics)



PCL for the more Adventurous



  • Upon application, the PCL interpreter evaluates `radius` (i.e., sets it equal to 1.0 in this example) and creates the curve. Note that the variable is passed to the session file in its unevaluated form.



PCL for the more Adventurous



  • B
    $# Session file patran.ses.01 started recording at 16-Aug-01 14:33:54

    $# Recorded by: MSC.Patran 2001



    REAL radius

    radius = 1.0

    STRING asm_create_patch_xy_created_ids[VIRTUAL]

    asm_const_patch_xyz( "1", "<10 10 0>", "[0 0 0]", "Coord 0", @

    asm_create_patch_xy_created_ids )

    $# 1 Patch created: Patch 1

    STRING sgm_edit_surface_add_h_edit_ids[VIRTUAL]

    sgm_edit_surface_add_hole( 1, `radius` , TRUE, "", "[5 5 0]", @

    "", "Surface 1", sgm_edit_surface_add_h_edit_ids )

    $# 1 Surface Edited: Surface 1

    $# Session file patran.ses.01 stopped recording at 16-Aug-01 14:34:52



    y using variables as parameters during MSC.Patran input, it is very easy to edit and change dimensions, mesh parameters, etc. in the session file.

PCL for the more Adventurous

A
#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()

dding a Graphical User Interface, GUI


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

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.



  1. Steps:

  1. Create variables using MSC.Patran’s command line

  2. Create/Surface/XYZ (use variables length and width)

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



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

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 i, j, status, NodeIds(1000)
LOGICAL flag
REAL xyz(1000, 3), pressure(100), time
GLOBAL STRING my_group[32], all_groups[32](100)


  • Dynamically allocated virtual strings and arrays

    INTEGER node_ids(VIRTUAL)
    STRING 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])


PCL Programming Basics

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


Download 1.08 Mb.

Share with your friends:
1   2   3   4   5   6   7   8   9   ...   25




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

    Main page