workshop 20 creating pcl functions - fsb online · workshop 20 creating pcl functions. ws20-2...

18
WS20-1 PAT302, Workshop 20, December 2004 Copyright2004 MSC.Software Corporation WORKSHOP 20 CREATING PCL FUNCTIONS

Upload: duongkhuong

Post on 12-Jun-2018

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-1PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

WORKSHOP 20

CREATING PCL FUNCTIONS

Page 2: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-2PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Page 3: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-3PAT302, Workshop 20, December 2004Copyright2004 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 arecreated by recording session files using corresponding previouslycreated named views. Using the session files PCL function files areeasily created. The PCL functions are compiled in MSC.Patran. Theviews can be obtained by using the compiled PCL functions.

Page 4: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-4PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Suggested Exercise Steps1. 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 .pcl6. 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.

Page 5: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-5PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Step 1. Create a database

Create a new database and set theNew 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 Modelunder Tolerance.

d. Set the Analysis Code andAnalysis Type to MSC.Nastranand Structural, respectively.

e. Click on OK.

b

c

d

e

Page 6: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-6PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Step 2. Import a Parasoid.xmt file

Import the model via parasolid.xmtfile.

a. File : Import…b. Change the Object and Source,

to Model and Parasolid.xmt,respectively.

c. Find and select the fileshield_v11.xmt_txt.

d. Click on Apply.

a

bc

d

Page 7: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-7PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Step 2. Import a Parasoid.xmt file (Cont.)

Shown here is the imported model

Page 8: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-8PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Step 3. Create Named Views

This next step involves creating twoviews for the model. Any two views canbe used, but for simplicity, a general viewwill 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 thisview whenever it is selected underSelect Named View in the NamedView Options form. Test out theview by changing it to any otherview and then returning to the formand selecting v1.

b

Page 9: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-9PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Step 3. Create Named Views (Cont.)

Create the second view, v2, byzooming 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 outthe views simply by changing the currentview(rotating, changing views, zoomingin, etc.) and clicking on either v1 or v2.

ab

c

de

Page 10: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-10PAT302, Workshop 20, December 2004Copyright2004 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

Page 11: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-11PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Step 4. Record Session Files (Cont.)

Create the second session file usingthe 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 ce

f

h

a

g

Page 12: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-12PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Step 5. Edit the session files

To edit the session files close thedatabase.

a. File : Quit.b. Find the directory with the

database and session files(e.g. use Explorer).

c. Copy the session fileskey1.ses and key2.ses.

d. Rename each copy file to key1.pcland key2.pcl, respectively.

a

bd

c

Page 13: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-13PAT302, Workshop 20, December 2004Copyright2004 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

Page 14: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-14PAT302, Workshop 20, December 2004Copyright2004 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 Enterf. Then enter !!input key2.pcl then click

Enter.

c

d

e

f

Page 15: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-15PAT302, Workshop 20, December 2004Copyright2004 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 orby using the view icons, aslong as it is a differentview from either v1 or v2).

b. Enter v1() into commandwindow (the modelshould return to theoriginal v1 view).

c. Change the model viewagain.

d. Enter v2() into thecommand window.

a

b

c

d

The model will automatically change to the two previously created views.

As long as this database is used the twocompiled PCL functions, key1.plb andkey2.plb, will be available.

Page 16: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-16PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation

Step 7. Compile the PCL Functions into the Patran Library

If it is desired to use the two PCLfunctions in a different databasecompile them into a library, then accessthe library via the p3epilog.pcl file.

a. In the command window enterthe following :!!compile key1.pcl keyand press Enter. Then,!!compile key2.pcl keyand pres Enter.

b. Quit Patran.c. Using a text editor create the

file p3epilog.pcl that containsthe following line!!library key.plband save it into the samedirectory that contains thedatabase and the correspondingsession files.

a

c

Page 17: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-17PAT302, Workshop 20, December 2004Copyright2004 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 view v1 and v2 under Viewinge. Enter either v1() or v2() into

the command window, and theviews should change accordingly.

f. Close the file and quit MSC.Patran.

a

b c

Instead of typing v1() or v2() in thecommand line it is possible to envoke thePCL commands using either key mapsor toolbar icons.

Page 18: WORKSHOP 20 CREATING PCL FUNCTIONS - FSB Online · WORKSHOP 20 CREATING PCL FUNCTIONS. WS20-2 PAT302, Workshop 20, ... Compile the PCL functions into the MSC.Patran library so …

WS20-18PAT302, Workshop 20, December 2004Copyright2004 MSC.Software Corporation