Machining

Inserting a PP Instruction before a Specified Activity


This macro CAAMaiInsertPPInstruction shows you how to insert a PP Instruction before a specified activity in a Manufacturing Program.

 

CAAMaiInsertPPInstruction is launched in CATIA. Open the file 'Sample_Part.CATPart' located in the CAAScdMaiUseCases module, go to the Prismatic Manufacturing Programmer workbench and run the macro.

CAAMaiInsertPPInstruction.CATScript is located in the CAAScdMaiUseCases module. 

 

CAAMaiManageMachiningAxisSystem includes 6 steps:

  1. Retrieve the active CATProcess document
  2. Retrieve the current Setup
  3. Retrieve the Manufacturing Program
  4. Open a box to specify the activity before which the PP Instruction should be inserted
  5. Create the PP Instruction
  6. Move the PP Instruction before the specified activity.

Retrieve the active CATProcess document

...
 
'*** Retrieve current Process
Dim MfgDoc1 As Document 
Set MfgDoc1 = CATIA.ActiveDocument 
 
...

Retrieves the active document and sets it in the variable MfgDoc1.

Retrieve the current Setup

...
 
'*** Retrieve current Process
	
Dim ActivityRef As AnyObject
Set ActivityRef = MfgDoc1.GetItem("Process")
 
'*** Retrieve current Setup

	Dim Setup1 As ManufacturingSetup

	If (ActivityRef.IsSubTypeOf("PhysicalActivity")) Then

		Set childs = ActivityRef.ChildrenActivities
		quantity = childs.Count

		if quantity <= 0 then
			Exit Sub
		End if

		NumberOfPO = 0

		For I=1 To quantity
			Set child = childs.Item(I)
			If (child.IsSubTypeOf("ManufacturingSetup")) Then
				Set Setup1 = child
				NumberOfPO = NumberOfPO +1
				Exit For
			End If
		Next   
	End If

	if NumberOfPO <= 0 then
	  Exit Sub
	End if
...

Retrieves the current Setup and sets it in the variable Setup1.

Retrieve the Manufacturing Program

...
'*** Retrieve current Program

Set ProgramList = Setup1.Programs

Dim Program1 As ManufacturingProgram
Set Program1 = ProgramList.GetElement(1)	
 
...

Retrieves the Manufacturing Program and sets it in the variable Program1.

Open a box to specify the activity before which the PP Instruction will be inserted

...
 '*** Box for user-defined referenced activity

Dim DefName As String
Dim RefActivityName As String
RefActivityName = InputBox("Add PP Instruction before activity", "Set name", DefName)
...

Opens a box to allow the user to specify the reference activity by its name.

Create the PP Instruction

...
 
Dim PPInstr As ManufacturingActivity
Set PPInstr = Program1.AddPPInstruction ("PPRINT/MY PP WORD") 
...

Creates the PP Instruction with the corresponding PP word.

Move the PP Instruction before the specified activity

...
 
'*** Move to the correct Position

Dim ActCur As ManufacturingActivity
Dim ActName As String

Set ActInProg = Program1.ChildrenActivities
quantity = ActInProg.Count

For I=1 To quantity
	set ActCur = ActInProg.Item(I)

	If (ActCur.IsSubTypeOf("ManufacturingActivity")) Then
		ActName = ActCur.Name

		if ActName = RefActivityName then
			Program1.MoveOperation ActCur,PPInstr
		End if
	End If
Next   
...

Moves the PP Instruction to the specified location.

[Top]


In Short

This use case has shown how to insert a PP Instruction before a specified activity in a Manufacturing Program.

[Top]


References

[1] Replaying a macro
[2] Machining automation objects 
[Top]

Copyright © 2002, Dassault Systèmes. All rights reserved.