Code:
Language="VBSCRIPT"
' Globale Variable definieren (auch für Subroutinen)
Private Ausgabe
' jetzt gehts weiterSub CATMain()
Dim myproduct As Product
Set myproduct = CATIA.ActiveDocument.Product
Box = MsgBox("Nomenklatur wird gleich dem Filename gesetzt", , "Hinweis")
' Die ganze Produktstruktur wird gescannt
ScanProductStructure myproduct
MsgBox "Alle Nomenklaturen wurden geändert"
End Sub
Sub ScanProductStructure(myproduct2 As Product) ' aus myproduct wird myproduct3
Dim currentprod As Product
Dim ii As Integer
On Error Resume Next
'für CATProducts__________________________________________________________________________
'Filename extrahieren und Endung ab . entfernen
Ausgabe = Left(myproduct2.ReferenceProduct.Parent.Name, InStrRev(myproduct2.ReferenceProduct.Parent.Name, ".") - 1)
myproduct2.Nomenclature = ""&Ausgabe&""
' Für CATPart_____________________________________________________________________________
For ii = 1 To myproduct2.Products.Count
Set currentprod = myproduct2.Products.Item(ii)
If currentprod.Products.Count = 0 Then
Err.Clear
'Filename extrahieren und Endung ab . entfernen
'für alle Parts
Ausgabe = Left(currentprod.ReferenceProduct.Parent.Name, InStrRev(currentprod.ReferenceProduct.Parent.Name, ".") - 1)
currentprod.Nomenclature = ""&Ausgabe&""
If Err.Number <> 0 Then
End If
Else
ScanProductStructure currentprod.ReferenceProduct
End If
Next
On Error GoTo 0
End Sub