09-09-2021
01:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-09-2021
01:19 AM
Thank for your help. I have found it. I mean Standart part is purchased item such as: nuts, bolts... here is my idea:
Public Sub modify_partlist()
' Make sure a drawing document is active.
Dim drawDoc As Document
On Error Resume Next
Set drawDoc = ThisApplication.ActiveDocument
If Not (TypeOf drawDoc Is DrawingDocument) Then
MsgBox "A drawing must be active."
End If
'Make sure a parts list is selected.
Dim partList As Object
On Error Resume Next
Set partList = drawDoc.SelectSet.Item(1)
If Not (TypeOf partList Is PartsList) Then
MsgBox "A parts list must be selected."
End If
Dim STT As Integer
STT = 1
'Sort to Title
partList.Sort (partList.PartsListColumns(5).Title)
'Index assembly
For i = 1 To partList.PartsListRows.Count
If partList.PartsListRows(i).ReferencedRows(1).BOMRow _
.BOMStructure <> BOMStructureEnum.kPurchasedBOMStructure _
And partList.PartsListRows(i).ReferencedRows(1).BOMRow.ComponentDefinitions(1) _
.Document.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject _
Then
partList.PartsListRows(i).Item(3).Value = STT
STT = STT + 1
End If
Next i
'Index part
For j = 1 To partList.PartsListRows.Count
If partList.PartsListRows(j).ReferencedRows(1).BOMRow _
.BOMStructure <> BOMStructureEnum.kPurchasedBOMStructure _
And partList.PartsListRows(j).ReferencedRows(1).BOMRow.ComponentDefinitions(1) _
.Document.DocumentType = DocumentTypeEnum.kPartDocumentObject _
Then
partList.PartsListRows(j).Item(3).Value = STT
STT = STT + 1
End If
Next j
'Index standard part
For k = 1 To partList.PartsListRows.Count
If partList.PartsListRows(k).ReferencedRows(1).BOMRow _
.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure _
Then
partList.PartsListRows(k).Item(3).Value = STT
STT = STT + 1
End If
Next k
'Sort to Item number
partList.Sort (partList.PartsListColumns(3).Title)
'Override to BOM
partList.SaveItemOverridesToBOM
End Sub