The code below works upto the function, why is it that i cant use functions in an expert rule where the language is VB? or am I doing something wrong?
Madaxe
Dim MyCATIA As Application
Dim MyProdDoc As ProductDocument
Dim MyProduct As Product
Dim MyProducts As Products
Dim MyParameters As Parameters
Dim MyListParameter As ListParameter
Dim MyList As List
Dim MyListSize As Integer
Dim Index As Integer
Dim Counter As Integer
Dim Flag As Integer
Set MyCATIA = CATIA
Set MyProdDoc = MyCATIA.ActiveDocument
Set MyProduct = MyProdDoc.Product
Set MyProducts = MyProduct.Products
Set MyParameters = MyProduct.Parameters
If MyParameters.Count > 0 Then
For Index = 1 To MyParameters.Count
If InStr(MyParameters.Item(Index).Name, "BOM_LIST" <> 0 Then
Flag = 1
End If
Next
If Flag = 0 Then
Set MyList = MyParameters.CreateList("BOM_LIST"
Else
Flag = 0
End If
Else
Set MyList = MyParameters.CreateList("BOM_LIST"
End If
Flag = 0
Set MyListParam = MyParameters.Item("BOM_LIST"
Set MyList = MyListParam.ValueList
MyListSize = MyList.Count
DigDown MyList, MyListSize, MyProduct
Private Function DigDown(MyList, MyListSize, MyProduct)
Dim Index As Integer
Dim Flag As Integer
Dim MyProducts As Products
Set MyProducts = MyProduct.Products
Flag = 0
For Each Product In MyProducts
Set MyProduct = Product.ReferenceProduct
If MyListSize > 0 Then
For Index = 1 To MyListSize2
If InStr(MyList.Item(Index).Name, Product.Name) <> 0 Then
Flag = 1
End If
Next
If Flag = 0 Then
MyList.Add Product
Else
Flag = 0
End If
Else
MyList.Add Product
End If
DigDown MyList, MyListSize, MyProduct
Next
End Function
|