Inventor General Discussion

Reply
Valued Contributor
dclunie
Posts: 70
Registered: ‎03-26-2008
Message 1 of 5 (549 Views)
Accepted Solution

Parts list sort Using Ilogic

549 Views, 4 Replies
11-07-2011 06:35 AM

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

 

 

 

Employee
MartinBernat
Posts: 23
Registered: ‎08-30-2011
Message 2 of 5 (537 Views)

Re: Parts list sort Using Ilogic

11-07-2011 08:27 AM 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

Valued Contributor
dclunie
Posts: 70
Registered: ‎03-26-2008
Message 3 of 5 (524 Views)

Re: Parts list sort Using ilogic

11-07-2011 11:43 AM 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

 

Valued Mentor
coreyparks
Posts: 483
Registered: ‎06-07-2010
Message 4 of 5 (512 Views)

Re: Parts list sort Using ilogic

11-07-2011 12:05 PM 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
IV2014 Factory Design Suite Ultimate
Windows 7 64 bit
Synergis Adept document management software
16gb RAM --- Nvidia Quadro 4000 2gb
Valued Contributor
dclunie
Posts: 70
Registered: ‎03-26-2008
Message 5 of 5 (503 Views)

Re: Parts list sort Using ilogic

11-07-2011 10:36 PM 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

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube