Okay my colleague told me this was a good start but he also wants to use it for the parts in a weldment.
We have different categories in the Vault for these. I added them to their templates so I could use them.
I made this iRule to empty the part number. It works but not for any sub assemblies or parts in an assembly.
What am I doing wrong?
'Define the open document
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
'Define all the documents in an assembly
Dim compDef As ComponentDefinition = oDoc.ComponentDefinition
Dim compOcc As ComponentOccurrence
Try
'Check if the Category is either Without Item or Weldment Part
If iProperties.Value("CUSTOM", "ItemCategory") = "Without Item" Or iProperties.Value("CUSTOM", "ItemCategory") = "Weldment Part"
'Set the Part Number to blank
iProperties.Value("Project", "Part Number") = ""
End If
Catch
End Try
For Each compOcc In compDef.Occurrences
Try
'Check if the Category is either Without Item or Weldment Part for each document in assembly
If iProperties.Value("CUSTOM", "ItemCategory") = "Without Item" Or iProperties.Value("CUSTOM", "ItemCategory") = "Weldment Part"
'Set the Part Number to blank
iProperties.Value("Project", "Part Number") = ""
End If
Catch
End Try
Next
'Update file
iLogicVb.UpdateWhenDone = True
EDIT: Got it!
I forgot to add comOcc.Name in front of the iProperty value.
Now it is working great.
For anyone who wants to add this to their Inventor here is the code:
Note:
- This will empty the part number for parts and assemblies with the category "Without Item" or "Weldment Part" in the Vault. These need to be added to the template of those parts.
- If the file doesn't have the property this rule will just skip it.
'Define the open document
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
'Define all the documents in an assembly
Dim compDef As ComponentDefinition = oDoc.ComponentDefinition
Dim compOcc As ComponentOccurrence
Try
'Check if the Category is either Without Item or Weldment Part
If iProperties.Value("CUSTOM", "ItemCategory") = "Without Item" Or iProperties.Value("CUSTOM", "ItemCategory") = "Weldment Part"
'Set the Part Number to blank
iProperties.Value("Project", "Part Number") = ""
End If
Catch
End Try
For Each compOcc In compDef.Occurrences
Try
'Check if the Category is either Without Item or Weldment Part for each document in assembly
If iProperties.Value(compOcc.Name,"CUSTOM", "ItemCategory") = "Without Item" Or iProperties.Value(compOcc.Name,"CUSTOM", "ItemCategory") = "Weldment Part"
'Set the Part Number to blank
iProperties.Value(compOcc.Name,"Project", "Part Number") = ""
End If
Catch
End Try
Next
'Update file
iLogicVb.UpdateWhenDone = True