Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all
I have found and modified the below rule to sort our parts list based on the part number.
The part number can be in several formats.
Type 1 - Drawing number "18000-01-01" always 11 characters long
Type 2 - DXF number "DXF 18000-01-A" always starts with DXF
Type 3 - Part Number "11111" always 5 characters long
Type 4 - anything else.
I keep getting an error with looking at the number of characters or looking for the 1st 3 characters of the part number
Can someone please point me in the right direction.
SyntaxEditor Code Snippet
' Set a reference to the drawing document.' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument ' Set a reference to the first parts list on the active sheet.' This assumes that a parts list is on the active sheet. Dim oPartList As PartsList oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1) Dim oPartNumber As PartsListCell Dim oType As PartsListCell 'Dim oPartNumberLength As Integer'Dim invCharPosition As Integer ' Iterate through the contents of the parts list. Dim i As Long For i = 1 To oPartList.PartsListRows.Count 'Get value from PartNumber column oPartNumber = oPartList.PartsListRows.Item(i).Item("DWG/PART No.") oType = oPartList.PartsListRows.Item(i).Item("PART TYPE") oPartNumberLength = Len(oPartNumber) oPartNumberStart = Left(oPartNumber,3) If oPartNumberLength = 11 Then oType.Value = "DWG" Else If oPartNumberStart = "DXF" Then oType.Value = "DXF" Else If oPartNumberLength = 5 Then oType.Value = "STD" Else oType.Value = "Other" End If Next oPartList.Sort("PART TYPE") oPartList.Renumber oPartList.SaveItemOverridesToBOM
Cheers
Donald
Inventor 2014
Solved! Go to Solution.