pirateincognito
Automotive
I'm a novice programmer but new to CATIA VBA. For a starting program, I'm simply trying to traverse the current product structure and print each part number.
The code runs perfectly as a .CATSCRIPT but when loaded into a CATVBA module, it fails spectacularly.
Run time error 438 'Object doesn't support this property or method' on line 10 ' Analyze (Prod)'
Usually this means your syntax is wrong. VBA seems to have trouble passing Prod as a parameter to the subroutine.
I have verified through debugging that Prod is in fact a VarType 'Product' with a valid assignment.
Nothing I've tried has worked. Any ideas eng-tips? Thanks.
The code runs perfectly as a .CATSCRIPT but when loaded into a CATVBA module, it fails spectacularly.
Run time error 438 'Object doesn't support this property or method' on line 10 ' Analyze (Prod)'
Usually this means your syntax is wrong. VBA seems to have trouble passing Prod as a parameter to the subroutine.
I have verified through debugging that Prod is in fact a VarType 'Product' with a valid assignment.
Nothing I've tried has worked. Any ideas eng-tips? Thanks.
Code:
Public Sub CATMain()
Dim AD As Document
Dim Prod As Product
Set AD = CATIA.ActiveDocument
Set Prod = AD.Product
' Debug.Print TypeName(AD)
' Debug.Print VarType(AD)
' Debug.Print TypeName(Prod)
' Debug.Print VarType(Prod)
Analyze (Prod)
End Sub
Public Sub Analyze(P As Product)
Debug.Print P.PartNumber
Dim PP As Products
Dim i As Integer
i = 0
Set PP = P.Products
Do While i < PP.Count
i = i + 1
Analyze (PP.Item(i))
Loop
End Sub