Many companies today are using MBD, model based definition, meaning the 3D CATPart contains all the information required to manufacturer the part (such as special notes, dimensions, tolerances, instructions, etc.) To do this the CATIA model will most likely contain captures, views, dimensions, and notes within an annotation set. The following example CATIA macro (CATVBA) will show you how:display captures

  1. Drill down to the captures and loop through them.
  2. Display a capture
  3. Activate a capture with SendKeys
  4. Find a View of the same name of the activated capture

Sub CATMain()

‘This code assumes that a CATPart file is the active document in CATIA

Dim partDocument1 As Document

Set partDocument1 = CATIA.ActiveDocument


‘—error handling for part doc————

On Error Resume Next

Set PartDoc = CATIA.ActiveDocument

Set Part = PartDoc.Part


If Err.Number = 0 Then


‘set the first annotation set

Set oAnnotationSets = Part.AnnotationSets

Dim AnnoSet1 As AnnotationSet

Set AnnoSet1 = oAnnotationSets.Item(1)


‘count the number of captures

NumberCaptures = AnnoSet1.Captures.Count

MsgBox “Number of annotation sets is: ” & oAnnotationSets.Count & ” Number of captures is: ” & NumberCaptures

‘Loop through captures

For j = 1 To NumberCaptures


‘display the current capture

Set CurrentCapture = AnnoSet1.Captures.Item(j)




‘—set capture j as the selection and activate it in order to edit and save the views———–

Dim sCapSel As Selection

Set sCapSel = CATIA.ActiveDocument.Selection


sCapSel.Add CurrentCapture


CATIA.RefreshDisplay = True

AppActivate “CATIA V5”

Application.Wait Now + TimeValue(“00:05:00”)

SendKeys “c:Activate” + Chr(13), True

Application.Wait Now + TimeValue(“00:05:00”)

CATIA.RefreshDisplay = True


‘show the name of the capture in a message box

CaptureName = CurrentCapture.Name

MsgBox “The activated capture is: ” & CaptureName

CATIA.RefreshDisplay = True


‘—add views to the selection

Dim sSelView As Selection

Set sSelView = CATIA.ActiveDocument.Selection

sSelView.Add oAnnotationSets.Item(1)


‘ search views for any with name matching captures

sSelView.Search “Name=” & CaptureName & “,sel”


‘count the number of views found

Dim viewFound As Integer

viewFound = sSelView.Count


If viewFound > 1 Then

MsgBox “Number of views found is ” & viewFound



MsgBox “No view associated with capture. Click OK to continue.”

End If

Next ‘j

‘—error handling and cleanup——-


‘error handling

MsgBox “Not a part document! Open in new window.”

End If

End Sub