# Navigating CATIA V6 Product Structure

## Navigating CATIA V6 Product Structure

Previously in CATAI V5 the product structure was reasonably simple to navigate, in CATIA V6 no so much and if your as dyslexic as I am it can be challenging.

Lets looks at a simple product structure of a root product and one child part. Things to keep in mind a 3Dpart may have multiple representations below it in this case there is a 3Dshape and a Drawing. If the child was converted or created as a product it may have many representations below it. Unfortunately there are no type flags indicating type of VPM Representation Instance.

The active Tab is the Active Editor, within which is an Active Object in this case a root product referred to as the VPM Root Occurrence.

Within this object is a collection called a VPM Occurrences, so each child of the assembly will be a VPM Occurrence. Once we have the child occurrence, we have to get the VPM Instance of that occurrence, and its associated VPM Reference.

This is very similar to CATIA V5 where we had to navigate from the instance to the reference. Next since CATIA v6 allows multiple Representation Instances we navigate to the VPM Representation Instances, so each child of the 3D Part is a VPM Representation Instance.

Once we have the child Rep Instance, we can again travel from Instance to Reference to get the VPM Representation Reference. If this is a Part or a Drawing or another type of rep reference we can use the GetItem method along with the type name to retrieve that object type.

Below is the CATScript (VBA) that navigates this structure as explained above.

'Get The Application Object
Dim ioCATIA As Application
Set ioCATIA = CATIA

'Get The Active Object i.e. Root object
Dim ioVPMRootOccurence As VPMRootOccurrence
Set ioVPMRootOccurence = ioCATIA.ActiveEditor.ActiveObject

' Get the Child Occurences i.e. the objects below the root
Dim ioVPMOccurences As VPMOccurrences
Set ioVPMOccurences = ioVPMRootOccurence.Occurrences

' Get the first Child Occurence
Dim ioOccurence As VPMOccurrence
Set ioOccurence = ioVPMOccurences.Item(1)

' Get the VPM Instance from the Child Occurence
Dim ioVPMInstance As VPMInstance
Set ioVPMInstance = ioOccurence.InstanceOccurrenceOf

' Get the VPM Reference from the VPM Instance
Dim ioVPMReference As VPMReference
Set ioVPMReference = ioVPMInstance.ReferenceInstanceOf

' Get the VPM Representation Instances
Dim ioVPMRepInstances As VPMRepInstances
Set ioVPMRepInstances = ioVPMReference.RepInstances

' A 3D Part may have multiple reps below it i.e. a Shape and a Drawing
' Get the first Representation Instance from the VPM Representation Instances
Dim ioVPMRepInstance As VPMRepInstance
Set ioVPMRepInstance = ioVPMRepInstances.Item(1)

' Get the VPM Representation Reference from the Representation Instance
Dim ioVPMRepReference As VPMRepReference
Set ioVPMRepReference = ioVPMRepInstance.ReferenceInstanceOf

' Get the Part from the VPM Representation Reference
Dim ioPart As Part
Set ioPart = ioVPMRepReference.GetItem("Part")