Dim oProdSelection As Selection
Dim oSkelDoc As PartDocument
Sub CATMain()
Dim oProdDoc As ProductDocument
Dim oProd As Product
Set oProdDoc = CATIA.ActiveDocument
Set oProd = oProdDoc.Product
Set oProdSelection = oProdDoc.Selection
oProdSelection.Clear
'modify next line to make sure that this is the Axis Systems skeleton repository
Set oSkelDoc = oProd.Products.Item("Skel.1").ReferenceProduct.Parent
CATIA.HSOSynchronized = False
Call ProcessAxisSystems(oProd)
CATIA.HSOSynchronized = True
End Sub
Sub ProcessAxisSystems(oProd As Product)
Dim oChildProd As Product
For Each oChildProd In oProd.Products
If oChildProd.HasAMasterShapeRepresentation Then
'it is a part. you can do whatever checks you'd like to make sure that this is a Part indeed.
'for the next line adjust the condition in order to identify the skeleton itself and
'to avoid copying-pasting from the same part.
If oChildProd.ReferenceProduct.PartNumber <> "Skel" Then
oProdSelection.Clear
oProdSelection.Add oChildProd
oProdSelection.Search "(((FreeStyle.'Axis System' + 'Part Design'.'Axis System') + 'Generative Shape Design'.'Axis System') + 'Functional Molded Part'.'Axis System'),sel"
oProdSelection.Copy
oProdSelection.Clear
oProdSelection.Add oSkelDoc.Part
oProdSelection.PasteSpecial ("CATPrtResult")
oProdSelection.Clear
oSkelDoc.Part.Update
oSkelDoc.Part.AxisSystems.Item(oSkelDoc.Part.AxisSystems.Count).Name = oChildProd.Name
'Else
'this is the Skel part
End If
Else
Call ProcessAxisSystems(oChildProd)
End If
Next
End Sub