Documentation of items that need to be moved or modified ...



Instructions to make a G-Post launch Macro for CATIA

Paste the following code into a Visual Basic Module and modify with the appropriate values.

This code will launch "CATIA_run_node_samp.bat". A copy of the BAT file is listed below.

'*************************************************************************************

'* Post Job

'*

'* This Script will allow the user to pick a machining operation from the process tree and then

'* prompt them to specify a name for the job. It will then create an apt file and run it through

'* a GPost.

'*

'* Version: 1.00

'* Date: 06/09/07

'* Programmer: Mike Wilson

'* Original Release: CATIA V5 R16 SP4

'*

'* Date: 07/11/07 Rev 1: Updated to work with R17 SP5 M Wilson

'*************************************************************************************

Dim Path As String

Dim myapt As String

Sub CATMain()

CreateApt

Shell ("cmd.exe /k " & "P:\CATIAV5\CAMAPT\Scripts\CATIA_run_node_samp.bat " & myapt & " UNCX01 11")

End Sub

Sub CreateApt()

Dim outputGen As ManufacturingOutputGenerator

Dim genData As ManufacturingGeneratorData

Dim UserName As String

UserName = CATIA.SystemService.Environ("UserName")

MsgBox "Select the Program you want"

Set outputGen = Sel("ManufacturingProgram")

myapt = InputBox("Name of Your Program?")

Path = "M:\@Dept. 96 Loft\CATIA_V5_TOOLS\APT\" & UserName & "\" & myapt

outputGen.InitFileGenerator "APT", Path & ".APT", genData

outputGen.RunFileGenerator genData

genData.ResetAllModalValues

End Sub

'Single Select Function

Public Function Sel(ObjType As String)

Set S2 = CATIA.ActiveDocument.Selection

CrvPicked = False

PathNotFinished = True

Do While PathNotFinished

ReDim InputObjectType(0)

InputObjectType(0) = ObjType

Status = S2.SelectElement2(InputObjectType, "Select the " & ObjType, False)

If (Status = "Cancel") Then

Exit Function

ElseIf (Status = "Redo" And Not CrvPicked) Then

ElseIf (Status = "Undo") Then

Exit Function

Else

If (Status "Redo") Then Set obj = S2.Item(1).Value

CrvPicked = True

PathNotFinished = False

End If

Loop

S2.Clear

Set Sel = obj

End Function

From the CATIA V5 screen perform the following functions:

A. Go to Tools\Macros

B. Go to Macro Libraries

C. Then goto Tools\Customize

D. Drag the Module on to a tool bar and run macro.

Contents of file: CATIA_run_node_samp.BAT

ECHO OFF

REM CATIA GPOST RUN FROM COMMAND LINE %1 APT FILE, %2 POST NAME %3 POST NUMBER

REM WITHOUT STARTING CIMPRO/SHELL FOR A NODE LICENSE

REM IF A REGULAR RUN BAT FILE OR SHELL COMMAND FAILS THEN YOUR CALLING PROGRAM MAY

REM HAVE TO LAUNCH USING THE COMMAND CMD/K "this BAT filename"

REM SAY APT INPUT FILE NAME IS %1 ARG = TEST %2 = UNCX01 %3 = 01

IF EXIST %1.APT GOTO L20

ECHO NO INPUT FILE...

PAUSE

GOTO L90

REM MAKE AN ASCII FILE NAMED TEST.MBX

REM WITH ONE LINE TEXT $$ ANY TEXT

:L20

ECHO $$ ANY TEXT >%1.MBX

REM RUN CATIA GPOST

E:\CAMSYS\WXAPT17 %1.APT %2%3

REM IF YOU DONT WANT THE USER TO HIT OK FOR

REM THE GPOST COMPLETED MSG THEN SET YOUR ENTRY

REM END_PROMPT = OFF IN YOUR CONFIG.TBL FILE

REM WAIT TILL ABOVE PROCESS IS COMPLETE

REM TEST.MBX FILE WILL NOT BE THERE

REM WHEN DONE AS GPOST WILL DELETE IT

:L30

E:\CAMSYS\GOSLEEP 3

IF EXIST %1.MBX GOTO L30

:L90

REM END OF FILE

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download