Hallo,
jedes Document verfügt über die Eigenschaft "TypeName", mit der sich bestimmen lässt, um was es sich handelt.
Also
Set oDocument = Catia.ActiveDocument
If TypeName(oDocument) = "ProductDocument" Then
' irgendwas
ElseIf TypeName(oDocument) = "PartDocument" Then
' irgendwas anderers
End if
Um Parts/Products in einer Produktstruktur auszulesen zählt man normlerweise die Childrens durch und geht nicht über die Catia.Documents.
Wenn die Strukturtiefe undefiniert ist, funktioniert das am besten rekursiv, d.h. mit einer Routine, die sich selbst aufruft. Also ungefähr so (sofern ich es aus dem Kopt richtig zusammen bekomme)
Public sMsgBox as String
Sub CATMain()
Set oRoot = Catia.ActiveDocument
Set oProducts = oRoot.Product.Products
SUB_ProdScan oProducts
Msgbox sMsgBox, 48, "Enthaltene Parts"
End Sub
Sub SUB_ProdScan(oProducts)
For x = 1 To oProducts.Count
Set oParentDoc = oProducts.Item(x).ReferenceProduct.Parent
If TypeName(oParentDoc) = "PartDocument" Then
sMsgBox = sMsgBox & VbLf & oParentDoc.Name
End if
If oProducts.Item(x).Products.Count > 0 Then
SUB_ProdScan oProducts.Item(x).Products
End If
Next
End Sub
Hoffe es hilft.
Gruss TomTom
------------------
tomtom1972
[Diese Nachricht wurde von tomtom1972 am 01. Feb. 2006 editiert.]
[Diese Nachricht wurde von tomtom1972 am 01. Feb. 2006 editiert.]
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP