Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Parts list sort Using Ilogic

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
dclunie
2914 Views, 4 Replies

Parts list sort Using Ilogic

I have got some ilogic code that i have patched together to sort my parts list in inventor which works great but it will not update all sheets at the same time as when we design we have multiple sheets with parts list on and the odd one without.

 

Can anyone help me to add to this code to update all sheets partlists and also recognise that some sheets will not have partslists on so this will need to skip. 

 

 

below is code that is used to sort

 

Format:HTML Format Version:1.0 StartHTML:     165 EndHTML:    4558 StartFragment:     314 EndFragment:    4526 StartSelection: 314 EndSelection:     314
SyntaxEditor Code Snippet

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 4558 StartFragment: 314 EndFragment: 4526 StartSelection: 314 EndSelection: 314
SyntaxEditor Code Snippet

'parts list sort Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oPartsList1 As PartsList oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1) oPartsList1.Sort("MATERIAL", 0, "L", 0, "W", 0) 'oPartsList1.Sort("ITEM", 1, "DESCRIPTION", 1, "QTY", 1) oPartsList1.Renumber oPartsList1.SaveItemOverridesToBOM
iLogicVb.UpdateWhenDone = True ThisApplication.ActiveView.Fit

 

 

 

4 REPLIES 4
Message 2 of 5
MartinBernat
in reply to: dclunie

Hi,

you're using DrawingDocument.ActiveSheet and its PartLists property (Item(1)) - this means you're sorting just the first partlist on the active sheet.

In order to do a sort on all partlists on all sheets you should iterate over DrawingDocument.Sheets property and then Sheet.PartLists property on each sheet. That means you should have 2 nested "for" loops.

 

Let me know if you need more advice. You can write me an email at martin (dot) bernat (at) autodesk (dot) com.

 

Thanks for your question.

 

Martin Bernat

Autodesk

Message 3 of 5
dclunie
in reply to: MartinBernat

Hi Martin

 

Thanks for the response but as I have very little knowledge of manipulating code I am to be honest struggling to achieve as explained in reply.

 

Would it be possible to show me some pasted code with the appropriate modified code so I can better understand where I'm going wrong.

 

Sorry to be cheeky but I am not experienced enough .

 

Regards

 

Dave

 

'parts list sort
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oPartsList1.Sort("PART NUMBER", 1, "DESCRIPTION", 1, "QTY", 1)
'oPartsList1.Sort("ITEM", 1, "DESCRIPTION", 1, "QTY", 1)
oPartsList1.Renumber
oPartsList1.SaveItemOverridesToBOM

iLogicVb.UpdateWhenDone = True
ThisApplication.ActiveView.Fit

 

Message 4 of 5
coreyparks
in reply to: dclunie

Try this code, it works for me anyway.  Currently only sorts by part number but does so on every sheet and skips sheets without a partlist on them.  Hope this helps.

 

On Error Resume Next
Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
Dim Sheet As Inventor.Sheet
Dim Cursheet As String
     Cursheet = oDrawDoc.ActiveSheet.Name
    
For Each oSheet In oDrawDoc.Sheets
        oSheet.Activate
Dim oPartsList As PartsList
    oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
        If Not oPartsList Is Nothing Then
         Resume Next
    Call oPartsList.Sort("ITEM")
End If
    Next
   

Please mark this response "Accept as solution" if it answers your question.
-------------------------------------------------------------------------------------
Corey Parks
Message 5 of 5
dclunie
in reply to: coreyparks

Many thanks  for the code it works great i have added some other areas to be sorted in vb and added additional lines to take you back to sheet 1 and update active view on all sheets .

 

On Error Resume Next
Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
Dim Sheet As Inventor.Sheet
Dim Cursheet As String
     Cursheet = oDrawDoc.ActiveSheet.Name
    
For Each oSheet In oDrawDoc.Sheets
        oSheet.Activate
Dim oPartsList As PartsList
    oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
        If Not oPartsList Is Nothing Then
         Resume Next
    'Call oPartsList.Sort("ITEM")
	Call oPartsList.Sort("PART NUMBER", 1, "DESCRIPTION", 1, "QTY", 1)
iLogicVb.UpdateWhenDone = True
ActiveSheet = ThisDrawing.Sheet("Sheet:1")
ThisApplication.ActiveView.Fit


End If
    Next

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report