Upload
jack-chen
View
67
Download
1
Embed Size (px)
Citation preview
S9-1PAT302, Section 9, June 2003
OVERVIEW OF PCL
What is PCL ? PCL is an acronym for Patran Command Language. It is a fully functional programming language, i.e. IF…THEN, FOR… Users can create functions in MSC.Patran. Functions can perform multiple tasks, and can eliminate repetitive steps.
How to use PCL ? 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.
S9-2PAT302, Section 9, June 2003
PCL BASICS
Common PCL Function layout
FUNCTION gap_results(x_disp)
REAL x_disp, gap_opening
IF (x_disp < 0.0001) THEN
gap_opening = 1
ELSE
gap_opening = 0
END IF
RETURN gap_opening
END FUNCTION
Start the function; include name(e.g. gap_results)
Define variables
Logic and commands used to define the function
Return the value of a variable
End the function
S9-3PAT302, Section 9, June 2003
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, …)
S9-4PAT302, Section 9, June 2003
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.
S9-5PAT302, Section 9, June 2003
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”)
S9-6PAT302, Section 9, June 2003
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-7PAT302, 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.
S9-8PAT302, Section 9, June 2003
CASE STUDY: CHANGE BLACK TO WHITE
Black to White White to Black
S9-9PAT302, Section 9, June 2003
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.]] )
END FUNCTION
Add this line
Add this line
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
S9-10PAT302, Section 9, June 2003
Now the icon is shown in the MSC.Patran Toolbar after it has been loaded.
CASE STUDY: CHANGE BLACK TO WHITE
S9-11PAT302, Section 9, June 2003
Create the model that the PCL function will be used for to create the pressure load.
CASE STUDY: FUNCTION FOR PRESSURE
(0,0,0)
(6.283,2,0)
(0,-2,2)
S9-12PAT302, Section 9, June 2003
Create the model that the PCL function will be used for to create the pressure load.
CASE STUDY: FUNCTION FOR PRESSURE
S9-13PAT302, Section 9, June 2003
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.
S9-14PAT302, Section 9, June 2003
CASE STUDY: FUNCTION FOR PRESSURE
Create the pressure load using the field created from the PCL function.
S9-15PAT302, Section 9, June 2003
The pressure load will look like this on the model.
CASE STUDY: FUNCTION FOR PRESSURE