Вы находитесь на странице: 1из 18

WS20-1

PAT302, Workshop 20, December 2004


Copyright 2004 MSC.Software Corporation
WORKSHOP 20
CREATING PCL FUNCTIONS
WS20-2
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
WS20-3
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Problem Description
This exercise involves creating two PCL functions that can be used
to easily change the view of a model. The PCL functions are
created by recording session files using corresponding previously
created named views. Using the session files PCL function files are
easily created. The PCL functions are compiled in MSC.Patran. The
views can be obtained by using the compiled PCL functions.
WS20-4
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Suggested Exercise Steps
1. Create a new database.
2. Import the parasolid.xmt file.
3. Create two views of the model.
4. Record two session files, each one created while selecting a unique view of the
model.
5. Copy the session files, and edit the copies to create PCL function files with
suffix .pcl
6. Compile the PCL functions into MSC.Patran, then use the functions to go to
the selected view.
7. Compile the PCL functions into the MSC.Patran library so that they can be
used for different databases.
WS20-5
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 1. Create a database
Create a new database and set the
New Model Tolerances.
a. Click on the File New icon.
b. Enter shield.db for the File
Name and click OK.
c. In the New Model Preferences
form, select Based on Model
under Tolerance.
d. Set the Analysis Code and
Analysis Type to MSC.Nastran
and Structural, respectively.
e. Click on OK.
b
c
d
e
WS20-6
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 2. Import a Parasoid.xmt file
Import the model via parasolid.xmt
file.
a. File : Import
b. Change the Object and Source,
to Model and Parasolid.xmt,
respectively.
c. Find and select the file
shield_v11.xmt_txt.
d. Click on Apply.
a
b
c
d
WS20-7
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 2. Import a Parasoid.xmt file (Cont.)
Shown here is the imported model
WS20-8
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 3. Create Named Views
This next step involves creating two
views for the model. Any two views can
be used, but for simplicity, a general view
will be used.
a. Go to the Iso 3 view.
b. Viewing : Named View Options
c. Click on Create View
d. Under Create New View enter v1.
e. Click Apply.
The first view, v1, has been created.
Patran will automatically return this
view whenever it is selected under
Select Named View in the Named
View Options form. Test out the
view by changing it to any other
view and then returning to the form
and selecting v1.
b
WS20-9
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 3. Create Named Views (Cont.)
Create the second view, v2, by
zooming in on the model.
a. Zoom in on the model as shown.
b. Viewing : Named View Options
c. Click on Create View
d. Under Create New View enter
v2.
e. Click Apply.
Both views have been created. Test out
the views simply by changing the current
view(rotating, changing views, zooming
in, etc.) and clicking on either v1 or v2.
a
b
c
d
e
WS20-10
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 4. Record Session Files
Record the first of two session files.
a. File : Session / Record
b. Enter key1 for the File Name.
c. Click on Apply.
d. Viewing : Named View
Options...
e. Under Select Named View
select v1.
f. File : Session / Record
g. Click on Stop.
h. Click on Cancel.
a
b c
e
f
g
h
WS20-11
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 4. Record Session Files (Cont.)
Create the second session file using
the same approach.
a. File : Session / Record
b. Enter key2 for File Name.
c. Click on Apply.
d. Viewing : Named View
Options
e. Select v2 under Select Named
View.
f. File : Session / Record
g. Click on Stop.
h. Click on Cancel.
b c
e
f
h
a
g
WS20-12
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 5. Edit the session files
To edit the session files close the
database.
a. File : Quit.
b. Find the directory with the
database and session files
(e.g. use Explorer).
c. Copy the session files
key1.ses and key2.ses.
d. Rename each copy file to key1.pcl
and key2.pcl, respectively.
a
b
d
c
WS20-13
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 5. Edit the session files (Cont.)
Open the .pcl files and edit each one as follows.
a. Open key1.pcl with a text editor program such as Notepad or Wordpad.
b. Delete the lines that begin with: $# (In this case, there are only 2 such lines).
c. BEFORE the line ga_viewport_view_set( default_viewport, v1 )
enter FUNCTION v1().
d. AFTER the last line enter END FUNCTION.
e. File / Save.
f. Open the second file, key2.pcl, and repeat steps a-e for key2.pcl, entering
FUNCTION v2() instead of FUNCTION v1().
b
c
d
WS20-14
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 6. Compile the PCL Functions into Patran
Open the previously created database,
shield.db, and compile the PCL functions.
a. Open Patran.
b. Click on the File Open icon.
c. Select shield.db.
d. Click on OK.
e. In the Patran command window enter
!!input key1.pcl then click Enter
f. Then enter !!input key2.pcl then click
Enter.
c
d
e
f
WS20-15
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 6. Compile the PCL Functions into Patran (Cont.)
Test the compiled functions .
a. Rotate the model to any
arbitrary view (manual or
by using the view icons, as
long as it is a different
view from either v1 or v2).
b. Enter v1() into command
window (the model
should return to the
original v1 view).
c. Change the model view
again.
d. Enter v2() into the
command window.
a
b
c
d
The model will automatically change to the two previously created views.
As long as this database is used the two
compiled PCL functions, key1.plb and
key2.plb, will be available.
WS20-16
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 7. Compile the PCL Functions into the Patran Library
If it is desired to use the two PCL
functions in a different database
compile them into a library, then access
the library via the p3epilog.pcl file.
a. In the command window enter
the following :
!!compile key1.pcl key
and press Enter. Then,
!!compile key2.pcl key
and pres Enter.
b. Quit Patran.
c. Using a text editor create the
file p3epilog.pcl that contains
the following line
!!library key.plb
and save it into the same
directory that contains the
database and the corresponding
session files.
a
c
WS20-17
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation
Step 7. Compile the PCL Functions into the Patran Library (Cont.)
Create a new database shield2.db,
then create the two views, v1 and v2.
a. Select File New.
b. Specify shield2.db.
c. Click OK.
d. Create viewv1 and v2 under Viewing
e. Enter either v1() or v2() into
the command window, and the
views should change accordingly.
f. Close the file and quit MSC.Patran.
a
b
c
Instead of typing v1() or v2() in the
command line it is possible to envoke the
PCL commands using either key maps
or toolbar icons.
WS20-18
PAT302, Workshop 20, December 2004
Copyright 2004 MSC.Software Corporation

Вам также может понравиться