Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Darkforce_the_ilogic_guy
99 Views, 0 Replies

I need to make a check if partlist is already sorted?

I need to make a check if partlist is already sorted?  I have this problem  I want the partlist to be sorted.  

 

My problem is If  I on save does a Save item ovverides to bom. It will show like the iam have not save the lates changes

 

Darkforce_the_ilogic_guy_1-1708439598666.png

 

 

 

but I don´t the partlist show this lighning , 

Darkforce_the_ilogic_guy_0-1708439529612.png

 

 

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  to the partlist if it is not sorted as it should be.. so I could simple dobble save.  but i am open to idears to fix it.. this is current code  (it will not run with the Save item ovverides to bom on our test users but all users not call JCM or jcm will run the Save item ovverides to bom command

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 <> 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