- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
I want to sort my partlist by group, with three groups consist: Assembly, part and standard part. I have an idea to sort it by get file extension and BOM Structured value on each row then renumber them. But, I don't know API to get that values over partlist row. Thanks for your help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @quanguyvl. Can you better explain what you mean by "part and standard part" (the last two out of three groupings)? I have some code you can play with that will get document type and BOMStructure from the document in each row, but I still have no idea how you plan to use these, or how you plan to renumber the whole PartsList using only these pieces of data. If you could explain your plans in more detail, and more specifically how you want everything to be ordered in the parts list, we might be able to help you out better, and maybe present better suited complete solutions.
Here is the iLogic rule code I have for you so far:
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.",vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oPList As PartsList
Try
oPList = oDDoc.ActiveSheet.PartsLists.Item(1)
Catch
MsgBox("No PartsList found on Active Sheet.", , "")
End Try
If IsNothing(oPList) Then Exit Sub
For Each oRow As PartsListRow In oPList.PartsListRows
Dim oRowDoc As Document = GetPListRowDoc(oRow)
If IsNothing(oRowDoc) Then Continue For
Dim oDocType As DocumentTypeEnum = oRowDoc.DocumentType
Dim oBOMStruct As BOMStructureEnum = oRowDoc.ComponentDefinition.BOMStructure
MsgBox("oDocType = " & oDocType.ToString & vbCrLf & "oBOMStruct = " & oBOMStruct.ToString,,"")
Next
End Sub
Function GetPListRowDoc(oPListRow As PartsListRow) As Document
If oPListRow.ReferencedRows.Count = 0 Then Exit Function
Dim oDBOMRow As DrawingBOMRow = oPListRow.ReferencedRows.Item(1)
'If oDBOMRow.Virtual Then Exit Function
Dim oRowDoc As Document
Try
oRowDoc = oDBOMRow.BOMRow.ComponentDefinitions.Item(1).Document
Catch
End Try
If Not IsNothing(oRowDoc) Then Return oRowDoc
End Function
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS
or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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