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)