Code:
Language="VBSCRIPT"Sub CATMain()
'Kopieren des Original PartBody
'--------------------------
Set documents1 = CATIA.Documents
Set partDocument1 = CATIA.ActiveDocument
Set selection1 = partDocument1.Selection
selection1.Clear
selection1.Search "(Name=*PartBody* & CATPrtSearch.BodyFeature),all"
selection1.Copy
'Erzeugen eines neuen Parts
'--------------------------
Set partDocument1 = documents1.Add("Part")
'Einfuegen des kopierten Bodies As Result With Link
'--------------------------
Set partDocument2= CATIA.ActiveDocument
Set selection2 = CATIA.ActiveDocument.selection
Set part2 = partDocument2.Part
Set selection2 = partDocument2.selection
selection2.Add part2
selection2.PasteSpecial "CATPrtAsResult"
part2.Update
'Kopierten Body als PartBody setzen
'--------------------------
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set bodies1 = part1.Bodies
Set body2 = bodies1.Item("PartBody")
part1.MainBody = body2
'Symmetry anlegen
'--------------------------
'neuer PartBody in Work
'--------------------------
part1.InWorkObject = body2
part1.Update
'Publizierung wird gesetzt
'--------------------------
Set partDocument1 = CATIA.ActiveDocument
Set product1 = partDocument1.GetItem(fileName)
Set reference1 = product1.CreateReferenceFromName(fileName&"/!xy plane")
Set publications1 = product1.Publications
Set publication1 = publications1.Add("xy plane")
publications1.SetDirect "xy plane", reference1
Set reference2 = product1.CreateReferenceFromName(fileName&"/!yz plane")
Set publication2 = publications1.Add("yz plane")
publications1.SetDirect "yz plane", reference2
Set reference3 = product1.CreateReferenceFromName(fileName&"/!zx plane")
Set publication3 = publications1.Add("zx plane")
publications1.SetDirect "zx plane", reference3
Set reference4 = product1.CreateReferenceFromName(fileName&"/!Absolute Axis System")
Set publication4 = publications1.Add("Absolute Axis System")
publications1.SetDirect "Absolute Axis System", reference4
Set reference5 = product1.CreateReferenceFromName(fileName&"/!PartBody")
Set publication5 = publications1.Add("PartBody")
publications1.SetDirect "PartBody", reference5
'leeren Body löschen
'--------------------------
Set oDoc = CATIA.ActiveDocument
Set oPart = oDoc.Part
Set oSel = oDoc.Selection
oSel.clear
for x = oPart.bodies.count to 1 step -1
Set oBody = oPart.bodies.item(x)
if oBody.shapes.count =0 then
oSel.add oBody
oSel.delete
oSel.clear
end if
next
'Elemente abwaehlen
'---------------------
Set oSel = CATIA.ActiveDocument.Selection
oSel.Clear
CATIA.StartCommand "Fit All In"
CATIA.RefreshDisplay = True
End Sub