CAAMaiMachiningPatternCreation includes 15 steps:
- Retrieve the active CATProcess document
- Retrieve the current setup
- Retrieve the Manufacturing View
- Create a Machining Pattern
- Retrieve the Design Pattern and the Design Holes
- Assign these Design Features to the Machining
Pattern
- Modify the Jump Distance of the Machining Pattern
- Deactivate point number3 of the Machining Pattern
- Activate point number 4 of the Machining Pattern
- Get the point numbers of the Machining Pattern
- Set point number 2 as start point
- Reverse the numbering of the Machining Pattern
- Add a Part Surface to the Machining Pattern
- Remove the Part Surface of the Machining Pattern
- Modify the Top Mode of the Machining Pattern
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 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.Product
...
|
.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
Create a Machining Pattern
...
'---------------------------------------------------------------
' Create a Machining Pattern
'---------------------------------------------------------------
Dim Features As ManufacturingFeatures
Set Features = MfgView.ManufacturingFeatures
Dim ManPattern As ManufacturingPattern
Set ManPattern = Features.Add ("MfgPatternUsage")
...
|
.Creates a Machining Pattern and sets it in the variable ManPattern
Retrieve the Design Pattern and the Design Holes
...
'---------------------------------------------------------------
' Retrieve the Design Pattern and the Design Holes
'---------------------------------------------------------------
'*** Retrieve design pattern
Dim documents1 As Documents
Set documents1 = CATIA.documents
Dim partDocument1 As Document
Set partDocument1 = documents1.Item("Plate-VBSample01.CATPart")
Dim part1 As Part
Set part1 = partDocument1.Part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Dim body1 As Body
Set body1 = bodies1.Item("MechanicalTool.1")
Dim shapes1 As Shape
Set shapes1 = body1.Shapes
Dim designpattern As Shape
Set designpattern = shapes1.Item("RectPattern.1")
'*** Retrieve design holes
Dim designhole1 As Shape
Dim designhole2 As Shape
Dim designhole3 As Shape
Dim designhole4 As Shape
Set designhole1 = shapes1.Item("Hole.1")
Set designhole2 = shapes1.Item("Hole.2")
Set designhole3 = shapes1.Item("Hole.3")
Set designhole4 = shapes1.Item("Hole.4")
...
|
Retrieves, from the CATPart document, the design pattern, the design
holes and sets them in the variables designpattern and designhole1,2,3,4
Assign these Design Features to the Machining
Pattern
...
'---------------------------------------------------------------
' Assign these Design Features to the Machining Pattern
'---------------------------------------------------------------
ManPattern.AddPosition designpattern,Prod,0
ManPattern.AddPosition designhole1,Prod,0
ManPattern.AddPosition designhole2,Prod,0
ManPattern.AddPosition designhole3,Prod,0
ManPattern.AddPosition designhole4,Prod,1
...
|
Assigns the couple 'design feature - product' to the machining
pattern. For performances reasons, the last parameter is set to 1 only in
the last assignment.
Modify the Jump Distance of the Machining Pattern
...
'---------------------------------------------------------------
' Modify the Jump Distance of the Machining Pattern
'---------------------------------------------------------------
Dim Jump As Parameter
Set Jump = ManPattern.GetAnAttribute("JumpDistance")
Jump.ValuateFromString("50mm")
...
|
Retrieves the Jump Distance of the machining pattern and sets it
to 50 mm.
Deactivate the point number 3 the Machining
Pattern
...
'---------------------------------------------------------------
' Deactivate the point number 3 of the Machining Pattern
'---------------------------------------------------------------
ManPattern.DeactivatePoint 3
...
|
Deactivates the point number 3
Activate the point number 4 the Machining Pattern
...
'---------------------------------------------------------------
' Activate the point number 4 of the Machining Pattern
'---------------------------------------------------------------
ManPattern.ActivatePoint 4
...
|
Activates the point number 4
Get the point numbers of the Machining Pattern
...
'---------------------------------------------------------------
' Read numbers
'---------------------------------------------------------------
Dim Numbers() As Variant
ManPattern.GetNumbers Numbers
...
|
Gets the point numbers of the pattern and put it in the Numbers array
Set the point number 2 as Start Point of the
Machining Pattern
...
'---------------------------------------------------------------
' Set the point number 2 as Start Point
'---------------------------------------------------------------
ManPattern.StartPoint 2
...
|
Sets the point number 2 as the start point of the machining pattern
Reverse the numbering of the Machining
Pattern
...
'---------------------------------------------------------------
' Reverse the numbering
'---------------------------------------------------------------
ManPattern.Reverse
...
|
Reverses the numbering of the machining pattern
Add a Part Surface to the Machining Pattern
...
'---------------------------------------------------------------
' Add a Part Surface to the Machining Pattern
'---------------------------------------------------------------
ManPattern.AddPartSurface PartSurface,Prod,1
...
|
Adds a part surface to the pattern
Remove the Part Surface of the Machining Pattern
...
'---------------------------------------------------------------
' Remove the Part Surface of the Machining Pattern
'---------------------------------------------------------------
ManPattern.RemovePartSurfaces
...
|
Removes all part surface defined on the pattern
Modify the Top Mode of the Machining Pattern
...
'---------------------------------------------------------------
' Modify the Top Mode of the Machining Pattern
'---------------------------------------------------------------
Dim TopMode As Parameter
Set TopMode = ManPattern.GetAnAttribute("TopMode ")
TopMode .ValuateFromString("MfgProjectPattern")
...
|
|