Code:
Sub CATMain()Dim UserSelektion As Selection
Set UserSelektion = CATIA.ActiveDocument.Selection
'_____________Abfrage kein Selekt Elemente _________________________________
For I = 1 to 1
on Error resume Next
NameLeerError = (UserSelektion.Item(I).Value.ReferenceProduct.Name)
if Err Then
Box = msgbox ("KEIN TEIL SELEKTIERT" , vbCritical, "Abbruch")
Exit sub
end if
next
'___________________________________________________________________________
'_____________Abfrage Selektierte Elemente _________________________________
For I = 1 to UserSelektion.Count
Dim SelectedProduct As Product
Set SelectedProduct = CATIA.ActiveDocument.Selection.Item2(I).Value
Dim doc As Document
Set doc = SelectedProduct.ReferenceProduct.Parent
If TypeName(doc) = "PartDocument" then
msgbox "Part"
'************** Code *****************
'************** Code *****************
end if
If TypeName(doc) = "ProductDocument" then
msgbox "Product"
'************** Code *****************
'************** Code *****************
end if
Next
'___________________________________________________________________________
End Sub