CATScript - How Do I know if an object is a part or a product below a product
CATScript - How Do I know if an object is a part or a product below a product
(OP)
In a CATScript CATIA appears to consider both part leaves and product leaves as "Products" (typename). What would be a way to differentiate between the two?
Thanks,
Jeff
Thanks,
Jeff





RE: CATScript - How Do I know if an object is a part or a product below a product
Language="VBSCRIPT"
Option Explicit
Sub catmain()
Dim rootprod As Product
Set rootprod = CATIA.ActiveDocument.Product
Dim indent As Integer
indent = 0
Call dumpProduct(rootprod, indent)
End Sub
Sub dumpProduct(aProd As Product, indent As Integer)
Dim ix As String
Dim i As Integer
For i = 1 To indent
ix = ix & " "
Next
Dim docname As String
docname = aProd.ReferenceProduct.Parent.Name
Dim theType As String
If InStr(docname, ".CATProduct") > 0 Then
theType = "Product"
ElseIf InStr(docname, ".CATPart") > 0 Then
theType = "Part"
Else
theType = "Unknown"
End If
'Debug.Print ix & aProd.PartNumber & " is a " & theType
If theType = "Product" Then
For i = 1 To aProd.Products.count
Call dumpProduct(aProd.Products.Item(i), indent + 1)
Next
End If
End Sub
Regards
Fernando
https://picasaweb.google.com/102257836106335725208