02-20-2024
06:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-20-2024
06:44 AM
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
but I don´t the partlist show this lighning ,
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