0% found this document useful (0 votes)
428 views

PCL

PCL is a programming language used in MSC Patran to create customizable functions. Users can write PCL functions to perform repetitive tasks, simplify workflows, and automate processes. PCL functions are compiled either within Patran or externally and can then be executed from the command window or loaded as a library. Functions use a common structure of defining variables, logic/commands, and returning a value. Examples demonstrate how to change default colors or create a pressure load field using PCL functions.

Uploaded by

Jack Chen
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
428 views

PCL

PCL is a programming language used in MSC Patran to create customizable functions. Users can write PCL functions to perform repetitive tasks, simplify workflows, and automate processes. PCL functions are compiled either within Patran or externally and can then be executed from the command window or loaded as a library. Functions use a common structure of defining variables, logic/commands, and returning a value. Examples demonstrate how to change default colors or create a pressure load field using PCL functions.

Uploaded by

Jack Chen
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

OVERVIEW OF PCL

What is PCL ?

PCL is an acronym for Patran Command Language. It is a fully functional programming language, i.e. IFTHEN, FOR Users can create functions in MSC.Patran. Functions can perform multiple tasks, and can eliminate repetitive steps. Create a PCL function. Compile the PCL function in either MSC.Patran or in the external PCL compiler. Once the PCL function is compiled it can be executed in MSC.Patran using the command window(line), or by including it in a library and have that loaded during the start of MSC.Patran.

How to use PCL ?


PAT302, Section 9, June 2003

S9-1

PCL BASICS

Common PCL Function layout


FUNCTION gap_results(x_disp)

Start the function; include name(e.g. gap_results) Define variables

REAL x_disp, gap_opening

IF (x_disp < 0.0001) THEN

Logic and commands used to define the function

gap_opening = 1 ELSE gap_opening = 0 END IF

Return the value of a variable End the function

RETURN gap_opening

END FUNCTION

PAT302, Section 9, June 2003

S9-2

COMPILE THE PCL FUNCTION

Compile and execute PCL functions directly in MSC.Patran.

To compile a function type the following command in the command window(line) of MSC.Patran:

!!input pcl_function_filename.pcl

To execute the function in MSC.Patran type the following command in the command window:

pcl_function_filename(variable1, variable2, variable3, )

PAT302, Section 9, June 2003

S9-3

COMPILE THE PCL FUNCTION (Cont.)

Alternatively, it is possible to compile PCL functions in the command prompt(e.g. C:\>) environment.

At the command prompt execute p3pclcomp.exe to enter the PCL environment. The commands for this environment are same as those in the MSC.Patran environment.

PAT302, Section 9, June 2003

S9-4

COMPILE THE PCL FUNCTION (Cont.)

It is possible to generate a library of PCL functions and have that library loaded during the start of MSC.Patran. To create a library use the following command:

!!library create library_name.plb

To add a PCL function to a library use the following command to compile, then assign it:

!!compile pcl_function_filename.pcl library_name.plb

To load a library during the start of MSC.Patran the following line needs to be added to the p3epilog.pcl file.

sys_library(ADD, library_name.plb)

PAT302, Section 9, June 2003

S9-5

CASE STUDY: CHANGE BLACK TO WHITE

Sometimes a still image in the MSC.Patran viewport will be captured for a report or presentation. Due to the default color settings of MSC.Patran the background will be black, and it may be necessary to change the background color to white and the entities which are colored white to black. Other changes of the colors may be necessary. The changes may need to be made before the image is captured. The steps used in MSC.Patran to change the background color from black to white are:

Access the Color Palette. Switch the background color specification from black to white. Switch the entities which are colored white to being colored black.

Instead of performing these three steps every time MSC.Patran is used, create a PCL function and use it to perform the color swapping task. The simplest method to create such a function is to perform the above tasks in a new MSC.Patran database, and then extract the function representing the above tasks from the session file.
S9-6

PAT302, Section 9, June 2003

CASE STUDY: CHANGE BLACK TO WHITE

Manual steps

Create an MSC.Patran database and access the color palette in the Display menu. Use the RGB option to change the colors. Change a color by sliding each color bar left or right. The color is determined by the intensity of all three colors mixed together.

PAT302, Section 9, June 2003

S9-7

CASE STUDY: CHANGE BLACK TO WHITE

Black to White
PAT302, Section 9, June 2003 S9-8

White to Black

CASE STUDY: CHANGE BLACK TO WHITE

Create PCL function from session file (continued)


Add two entries in the text file to create a PCL function Save the file, calling it swap_bw.pcl

Add this line

FUNCTION swap_b_to_w() ga_lookup_colors_set( "standard_colortable", 0, 16, [[1., 1., 1.][1., 0., 0.][ @ 0., 1., 0.][1., 1., 0.][0., 0., 1.][1., 0., 1.][0., 1., 1.][0., 0., 0.][1., @ 0.47, 0.][1., 0.80000001, 0.][0., 0.5, 0.][0., 0.75, 0.][0., 0., 0.67000002][ @ 0., 0.60000002, 1.][1., 0.40000001, 1.][1., 0.75, 1.]] )

Add this line

END FUNCTION

PAT302, Section 9, June 2003

S9-9

CASE STUDY: CHANGE BLACK TO WHITE

Now the icon is shown in the MSC.Patran Toolbar after it has been loaded.

PAT302, Section 9, June 2003

S9-10

CASE STUDY: FUNCTION FOR PRESSURE

Create the model that the PCL function will be used for to create the pressure load.
(0,0,0)

(6.283,2,0)

(0,-2,2)

PAT302, Section 9, June 2003

S9-11

CASE STUDY: FUNCTION FOR PRESSURE

Create the model that the PCL function will be used for to create the pressure load.

PAT302, Section 9, June 2003

S9-12

CASE STUDY: FUNCTION FOR PRESSURE

Create the Spatial PCL Function field using the complied PCL function hydro_pressure.

Type the function name and the variables in the Scalar Function box.

PAT302, Section 9, June 2003

S9-13

CASE STUDY: FUNCTION FOR PRESSURE

Create the pressure load using the field created from the PCL function.

PAT302, Section 9, June 2003

S9-14

CASE STUDY: FUNCTION FOR PRESSURE


The pressure load will look like this on the model.

PAT302, Section 9, June 2003

S9-15

You might also like