Machining

Managing a Machining Axis System Activity


This macro CAAMaiManageMachiningAxisSystem shows you how to create and manage a Machining Axis System.

 

CAAMaiManageMachiningAxisSystem 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.

CAAMaiManageMachiningAxisSystem.CATScript is located in the CAAScdMaiUseCases module. 

 

CAAMaiManageMachiningAxisSystem includes 7 steps:

  1. Retrieve the active CATProcess document
  2. Retrieve the  current setup
  3. Retrieve the Manufacturing View
  4. Retrieve the Manufacturing Program
  5. Insert a Coordinate System activity and assign its feature
  6. Manage activity as an Origin and sets Origin Group and Number
  7. Manage activity as a Machining Axis and Assign Part Axis System
  8. Manage activity as a Machining Axis and Assign Point and Direction

Retrieve the active CATProcess document

...
 
'--------------------------------------------------------------- 
' Retrieve the active CATProcess document  
'---------------------------------------------------------------
Dim MfgDoc1 As Document 
Set MfgDoc1 = CATIA.ActiveDocument 
 
...

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

Retrieve the current setup

...
 
'--------------------------------------------------------------- 
' Retrieve the current setup  
'---------------------------------------------------------------
 
'*** Retrieve current Process Root
 
Dim ActivityRef As AnyObject
Set ActivityRef = MfgDoc1.GetItem("Process")
 
Dim Setup1 As ManufacturingSetup
Dim childs As Activities
Dim child As Activity
 
If (ActivityRef.IsSubTypeOf("PhysicalActivity")) Then
 
  Set childs = ActivityRef.ChildrenActivities
  quantity = childs.Count
 
  If quantity <= 0 Then
    Exit Sub
  End If
 
  NumberOfSetup = 0
 
  For I=1 To quantity
          Set child = childs.Item(I)
          If (child.IsSubTypeOf("ManufacturingSetup")) Then
                Set Setup1 = child
                NumberOfSetup = NumberOfSetup +1
                Exit For
          End If 
  Next
 
End If
 
If NumberOfSetup <= 0 Then
     Exit Sub
End If
 
'*** Retrieve current Product linked to the current setup
 
Dim Prod As Product
Set Prod = SetUp1.GetProductInstance
 
...

.Retrieves the current process and, from this process, the current setup. Retrieves also the product linked to the setup .

Retrieve the Manufacturing View

...
 
'--------------------------------------------------------------- 
' Retrieve the Manufacturing View  
'---------------------------------------------------------------
Dim MfgView As ManufacturingView 
Set MfgView = Setup1.GetManufacturingView 
 
...

 Retrieves the Manufacturing View and sets it in the variable MfgView

Retrieve the Manufacturing Program

...
 
'--------------------------------------------------------------- 
' Retrieve the Manufacturing Program
'---------------------------------------------------------------
Set ProgramList = Setup1.Programs
NumberOfProgram = ProgramList.Count

Set Program1 = ProgramList.GetElement(1) 
 ...

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

Insert a Coordinate System activity and assign its feature

...
 
'--------------------------------------------------------------- 
' Insert a Coordinate System activity and assign its feature
'---------------------------------------------------------------
 
'*** Retrieve design pattern
 
Set MyFeature = MfgView.ManufacturingFeatures.Add("MfgMachiningAxisSystem")

Set MachAxis = Program1.AppendOperation ("CoordinateSystem",1)

MachAxis.SetFeature(MyFeature)
...

Insert a Coordinate System in the Program and assign corresponding feature.

Manage activity as an Origin and sets Origin Group and Number

...
 
'--------------------------------------------------------------- 
' Manage activity as an Origin and sets Origin Group and Number
'---------------------------------------------------------------
 
MyFeature.Origin = 1

MyFeature.OriginNumber = 2

MyFeature.OriginGroup = 3
 
...

Assigns origin number and origin group to feature used as an Origin

Manage activity as a Machining Axis and Assign Part Axis System

...
 
'--------------------------------------------------------------- 
' Manage activity as a Machining Axis and Assign Part Axis System 
'---------------------------------------------------------------
 
MyFeature.Origin = 0

set part1 = PartDoc1.Part
Set axisSystems = part1.AxisSystems

Language="VBSCRIPT"

'*******************************************************************************************
'*
'* Main Entry  Point
'*
'*******************************************************************************************

Sub CATMain()
	
'*******************************************************************************************
'Declarations
'*******************************************************************************************

	Dim Count1 As VARIANT
	Dim MyHole As Hole
	Dim Rel As Relations
	Dim Setup1 As ManufacturingSetup
	Dim Program1 As ManufacturingProgram
	Dim MachAxis As ManufacturingOperation
	Dim MfgDoc1 As Document
	Dim ActivityRef As AnyObject
	Dim Feature As CATIABase
	Dim MfgView As ManufacturingView
	Dim MfgFeatures As ManufacturingFeatures

	Set MfgDoc1 = CATIA.ActiveDocument
	Set PartDoc1 = CATIA.Documents.Item("Sample_Part.CATPart")
	'MsgBox PartDoc1.Name
	Set ActivityRef = MfgDoc1.GetItem("Process")
	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

'*** Retrieve current Program
'***

	Set ProgramList = Setup1.Programs
	NumberOfProgram = ProgramList.Count

	Set Product = Setup1.GetProductInstance

	Set MfgView = Setup1.GetManufacturingView

	Set MyFeature = MfgView.ManufacturingFeatures.Add("MfgMachiningAxisSystem")

	Set Program1 = ProgramList.GetElement(1)	
	Set MachAxis = Program1.AppendOperation ("CoordinateSystem",1)

	MachAxis.SetFeature(MyFeature)

	'MsgBox MyFeature.Name

	MyFeature.Origin = 1
	'MsgBox MyFeature.Origin

	MyFeature.OriginNumber = 2
	'MsgBox MyFeature.OriginNumber

	MyFeature.OriginGroup = 3
	'MsgBox MyFeature.OriginGroup
	
	MyFeature.Origin = 0
	'MsgBox MyFeature.Origin

	set part1 = PartDoc1.Part
	Set axisSystems = part1.AxisSystems

	Set axisSystem = axisSystems.Item(1)

	Call MyFeature.SetPartAxisSystem (axisSystem,Setup1.GetProductInstance)

	Set hybridBodies1 = part1.HybridBodies

	Set hybridBody1 = hybridBodies1.Item("Open_body.1")

	Set hybridShapes1 = hybridBody1.HybridShapes

	Set hybridShapePointCoord2 = hybridShapes1.Item("Point.1")

	Call MyFeature.SetOriginPoint( hybridShapePointCoord2,Setup1.GetProductInstance)

	Call MyFeature.SetOriginXDirection (0.0,0.0,-1.0)
	Call MyFeature.SetOriginZDirection (-1.0,0.0,0.0)

End Sub
Set axisSystem = axisSystems.Item(1)

Call MyFeature.SetPartAxisSystem (axisSystem,Setup1.GetProductInstance)
 
...

Assigns Part Axis System to Machining Axis System

Manage activity as a Machining Axis and Assign Point and Direction

...
 
'--------------------------------------------------------------- 
' Manage activity as a Machining Axis and Assign Point and Direction
'---------------------------------------------------------------
 
Set hybridBodies1 = part1.HybridBodies

Set hybridBody1 = hybridBodies1.Item("Open_body.1")

Set hybridShapes1 = hybridBody1.HybridShapes

Set hybridShapePointCoord2 = hybridShapes1.Item("Point.1")

Call MyFeature.SetOriginPoint( hybridShapePointCoord2,Setup1.GetProductInstance)

Call MyFeature.SetOriginXDirection (0.0,0.0,-1.0)
Call MyFeature.SetOriginZDirection (-1.0,0.0,0.0)
 
...

Assigns point and coordinate of axis to Machining Axis System

 

 

[Top]


In Short

This use case has shown how to create a Machining Pattern and to assign design features to it.

[Top]


References

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

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