get Part Number of referenced parts in Parts List

get Part Number of referenced parts in Parts List

emanuel.c
Collaborator Collaborator
184 Views
1 Reply
Message 1 of 2

get Part Number of referenced parts in Parts List

emanuel.c
Collaborator
Collaborator

How can I get the Part Number of each document (line) existing on a parts list?

I'm traversing each line in the parts list but don't know how to access part numbers of those referenced documents.

Thank you!

0 Likes
Accepted solutions (1)
185 Views
1 Reply
Reply (1)
Message 2 of 2

emanuel.c
Collaborator
Collaborator
Accepted solution

Oh, I found it in the end...

 

If Not ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
	MessageBox.Show("Hey this rule only runs in Drawing Documents!")
	Exit Sub
End If

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oPartsList As PartsList
Dim oPartsListRow As PartsListRow
'Define Sheet counter
Dim iSheetCount As Integer = 0

'iterate through all sheets
For Each oSheet In oDrawDoc.Sheets
	iSheetCount = iSheetCount + 1
	'Define Parts List counter
	Dim iPartsListCount As Integer = 0
	'iterate through all Parts List, if there are more than 1	
	For Each oPartsList In oSheet.PartsLists
		Dim oPartsListName As String
		oPartsListName = oPartsList.Title
		iPartsListCount = iPartsListCount + 1
		'Define row counter
		Dim iRowCount As Integer = 0
		For i = 1 To oPartsList.PartsListRows.Count
			'skip invisible lines
			If oPartsList.PartsListRows(i).Visible = "True" Then
				iRowCount = iRowCount + 1
				'Get Column "Part Number"
				oCell = oPartsList.PartsListRows.Item(i).Item("PART NUMBER")			
				Dim oPartNum As String = oCell.Value				
				MessageBox.Show("Sheet " & "(" & iSheetCount & ")" & _
					vbLf & "Parts List " & "(" & iPartsListCount & ")" & " Named: " & oPartsListName & _
					vbLf & vbLf & "Line " & "(" & iRowCount & ")" & " PART NUMBER: " & oPartNum)				
			Else
				'Skip invisible lines
			End If				
		Next
	Next
Next

 

0 Likes