<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic I need to make a check if partlist is already sorted? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/i-need-to-make-a-check-if-partlist-is-already-sorted/m-p/12571405#M163965</link>
    <description>&lt;P&gt;I need to make a check if partlist is already sorted?&amp;nbsp; I have this problem&amp;nbsp; I want the partlist to be sorted.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is If&amp;nbsp; I on save does a Save item ovverides to bom. It will show like the iam have not save the lates changes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Darkforce_the_ilogic_guy_1-1708439598666.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1328199i5665F59C310DC5D3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Darkforce_the_ilogic_guy_1-1708439598666.png" alt="Darkforce_the_ilogic_guy_1-1708439598666.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I don´t the partlist show this lighning ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Darkforce_the_ilogic_guy_0-1708439529612.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1328197iB9E74A1137C8EBC4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Darkforce_the_ilogic_guy_0-1708439529612.png" alt="Darkforce_the_ilogic_guy_0-1708439529612.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idear how to fix this. ? I think if might be fix if it only do the Save item ovverides to bom if there is any change&amp;nbsp; to the partlist if it is not sorted as it should be.. so I could simple dobble save.&amp;nbsp; but i am open to idears to fix it.. this is current code&amp;nbsp; (it will not run with the&amp;nbsp;Save item ovverides to bom on our test users but all users not call JCM or jcm will run the&amp;nbsp;Save item ovverides to bom command&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main()
    Try
        Dim drawing As DrawingDocument = ThisApplication.ActiveDocument
        Dim sheetsNumber = drawing.Sheets.Count


        For i = 1 To sheetsNumber

            Dim oPartslistCheck As PartsList
            oPartslistCheck = drawing.Sheets(i).PartsLists(1)

            Dim oDoc As DrawingDocument
            oDoc = drawing

            Call oDoc.SelectSet.Select(oPartslistCheck)

            'InventorVb.RunMacro("ApplicationProject", "PartsListSort", "FormatSelectedPartsList")
            FormatSelectedPartsList()
        Next
    Catch

    End Try
End Sub


#Region "VBA to iLogic"

'Option Explicit
'Option Base 1


Public Function GetActiveDrawing() As DrawingDocument

    If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
        GetActiveDrawing = ThisApplication.ActiveDocument
    Else
        MsgBox("Must have a drawing active", MsgBoxStyle.OkOnly, "Error")
    End If

End Function



Public Function GetSelectedPartsList() As PartsList

    Dim oDrawDoc As DrawingDocument
    oDrawDoc = GetActiveDrawing()
    If oDrawDoc Is Nothing Then Exit Function

    Dim oSelectSet As SelectSet


    oSelectSet = oDrawDoc.SelectSet

    If oSelectSet.Count = 0 Then Exit Function
    If oSelectSet.Item(1).Type &amp;lt;&amp;gt; ObjectTypeEnum.kPartsListObject Then Exit Function
    GetSelectedPartsList = oSelectSet.Item(1)



End Function



Public Function FormatPartsList(oPartsList As PartsList) As PartsList
oNAME = ThisApplication.GeneralOptions.UserName
    On Error Resume Next

    oPartsList.Sort ("PART NUMBER", True)
    oPartsList.Renumber()
	
	
	If oNAME = "jcm" Or oNAME = "JCM"  Then
		
	Else
		 oPartsList.SaveItemOverridesToBOM()
	End If
	
    

    FormatPartsList = oPartsList

End Function



Public Sub FormatSelectedPartsList()

    Dim oPartsList As PartsList
    oPartsList = GetSelectedPartsList
    If oPartsList Is Nothing Then Exit Sub

    FormatPartsList (oPartsList)

End Sub
#End Region&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Feb 2024 14:44:08 GMT</pubDate>
    <dc:creator>Darkforce_the_ilogic_guy</dc:creator>
    <dc:date>2024-02-20T14:44:08Z</dc:date>
    <item>
      <title>I need to make a check if partlist is already sorted?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/i-need-to-make-a-check-if-partlist-is-already-sorted/m-p/12571405#M163965</link>
      <description>&lt;P&gt;I need to make a check if partlist is already sorted?&amp;nbsp; I have this problem&amp;nbsp; I want the partlist to be sorted.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is If&amp;nbsp; I on save does a Save item ovverides to bom. It will show like the iam have not save the lates changes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Darkforce_the_ilogic_guy_1-1708439598666.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1328199i5665F59C310DC5D3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Darkforce_the_ilogic_guy_1-1708439598666.png" alt="Darkforce_the_ilogic_guy_1-1708439598666.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I don´t the partlist show this lighning ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Darkforce_the_ilogic_guy_0-1708439529612.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1328197iB9E74A1137C8EBC4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Darkforce_the_ilogic_guy_0-1708439529612.png" alt="Darkforce_the_ilogic_guy_0-1708439529612.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idear how to fix this. ? I think if might be fix if it only do the Save item ovverides to bom if there is any change&amp;nbsp; to the partlist if it is not sorted as it should be.. so I could simple dobble save.&amp;nbsp; but i am open to idears to fix it.. this is current code&amp;nbsp; (it will not run with the&amp;nbsp;Save item ovverides to bom on our test users but all users not call JCM or jcm will run the&amp;nbsp;Save item ovverides to bom command&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main()
    Try
        Dim drawing As DrawingDocument = ThisApplication.ActiveDocument
        Dim sheetsNumber = drawing.Sheets.Count


        For i = 1 To sheetsNumber

            Dim oPartslistCheck As PartsList
            oPartslistCheck = drawing.Sheets(i).PartsLists(1)

            Dim oDoc As DrawingDocument
            oDoc = drawing

            Call oDoc.SelectSet.Select(oPartslistCheck)

            'InventorVb.RunMacro("ApplicationProject", "PartsListSort", "FormatSelectedPartsList")
            FormatSelectedPartsList()
        Next
    Catch

    End Try
End Sub


#Region "VBA to iLogic"

'Option Explicit
'Option Base 1


Public Function GetActiveDrawing() As DrawingDocument

    If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
        GetActiveDrawing = ThisApplication.ActiveDocument
    Else
        MsgBox("Must have a drawing active", MsgBoxStyle.OkOnly, "Error")
    End If

End Function



Public Function GetSelectedPartsList() As PartsList

    Dim oDrawDoc As DrawingDocument
    oDrawDoc = GetActiveDrawing()
    If oDrawDoc Is Nothing Then Exit Function

    Dim oSelectSet As SelectSet


    oSelectSet = oDrawDoc.SelectSet

    If oSelectSet.Count = 0 Then Exit Function
    If oSelectSet.Item(1).Type &amp;lt;&amp;gt; ObjectTypeEnum.kPartsListObject Then Exit Function
    GetSelectedPartsList = oSelectSet.Item(1)



End Function



Public Function FormatPartsList(oPartsList As PartsList) As PartsList
oNAME = ThisApplication.GeneralOptions.UserName
    On Error Resume Next

    oPartsList.Sort ("PART NUMBER", True)
    oPartsList.Renumber()
	
	
	If oNAME = "jcm" Or oNAME = "JCM"  Then
		
	Else
		 oPartsList.SaveItemOverridesToBOM()
	End If
	
    

    FormatPartsList = oPartsList

End Function



Public Sub FormatSelectedPartsList()

    Dim oPartsList As PartsList
    oPartsList = GetSelectedPartsList
    If oPartsList Is Nothing Then Exit Sub

    FormatPartsList (oPartsList)

End Sub
#End Region&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 14:44:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/i-need-to-make-a-check-if-partlist-is-already-sorted/m-p/12571405#M163965</guid>
      <dc:creator>Darkforce_the_ilogic_guy</dc:creator>
      <dc:date>2024-02-20T14:44:08Z</dc:date>
    </item>
  </channel>
</rss>

