jzecha
Aerospace
- Jan 20, 2016
- 236
I have the below code and want to update it to create a list of all the parts missing material instead of a message box listing only one part at a time.
The main issue with tis code is that it pops the message box even with repeat part numbers, I would like to modify it so it only shows each part missing material once.
My guess is I need to create an Array to list each part missing Material and then each time a part is found missing material, it checks it to the array.
But I couldn't figure out a good way to do that.
The second half of that is then, how do I list all the values in the Array in a Msgbox?
The main issue with tis code is that it pops the message box even with repeat part numbers, I would like to modify it so it only shows each part missing material once.
My guess is I need to create an Array to list each part missing Material and then each time a part is found missing material, it checks it to the array.
But I couldn't figure out a good way to do that.
The second half of that is then, how do I list all the values in the Array in a Msgbox?
Code:
Sub CATMain()
Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Set Inertias = TheSPAWorkbench.Inertias
Set Document = CATIA.ActiveDocument
Dim Selection1 As Selection
Set selection1 = Document.Selection
selection1.Search "(CATProductSearch.Part),all"
for k = 1 to Selection1.Count
Set Body = Selection1.Item(k).Value
Set inertia = Inertias.Add (Body)
if Inertia.Density <> 1000 Then
'Do Nothing
Else
MsgBox Selection1.Item(k).LeafProduct.PartNumber & " Has No Material Applied", vbInformation, "No Material Has Been Applied"
End If
Next
MsgBox "If There Were No Previous Notifications, All Details Have Material Applied To Them."
End Sub