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

11 REPLIES 11
Reply
Message 1 of 12
mcgyvr
1424 Views, 11 Replies

Parts list auto sort

Who do I have to sleep with or pay off to get automatic parts list sorting for the parts list in Inventor?

I just want to set in my defaults (style or application options or whatever) that I always sort by part number. Then whenever I place a parts list it "automatically" comes in sorted by part number, and whenever I make a change to the model and go back to the drawing it has "automatically" resorted and changed balloon numbering (if necessary) without me having to do anything..

Having to do this all day long in inventor makes me crazy.. So much power in this software but something so basic like parts list sorting is still done manually.

I already put in a wishlist at Augi (for whatever thats worth)

/end slight rant


-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
11 REPLIES 11
Message 2 of 12
Josh_Petitt
in reply to: mcgyvr

>Who do I have to sleep with

Lynn Allen?

(so sorry that was wrong, but I couldn't help myself 🙂 )

Below is a macro that I wrote to sort our parts list. It requires a button click, but it is way better than going thru all the clicks each time.




Public Function FormatPartsList(oPartsList As PartsList) As PartsList

On Error Resume Next
' sort by length thick and width first
' oPartsList.Sort "THICK", True, "WIDTH", True, "LENGTH", True
' now sort by sub-assembly, material name
oPartsList.Sort "SUB-ASSEMBLY", False, "MATERIAL NAME", True, "PART NUMBER", True

oPartsList.Renumber
If Err Then
Err.Clear
MsgBox "Could not sort Parts List", , "Error"
End If

Set FormatPartsList = oPartsList

End Function




Public Sub FormatSelectedPartsList()

Dim oPartsList As PartsList
Set oPartsList = GetSelectedPartsList
If oPartsList Is Nothing Then Exit Sub

FormatPartsList oPartsList

End Sub


Public Function GetSelectedPartsList() As PartsList

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = GetActiveDrawing
If oDrawDoc Is Nothing Then Exit Function

Dim oSelectSet As SelectSet
Set oSelectSet = oDrawDoc.SelectSet

If oSelectSet.Count = 0 Then Exit Function
If oSelectSet.Item(1).Type <> kPartsListObject Then Exit Function
Set GetSelectedPartsList = oSelectSet.Item(1)

End Function


Public Function GetActiveDrawing() As DrawingDocument

If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
Set GetActiveDrawing = ThisApplication.ActiveDocument
Else
MsgBox "Must have a drawing active", vbOKOnly, "Error"
End If

End Function
Message 3 of 12
mcgyvr
in reply to: mcgyvr

Josh,
Can you tell me what I need to do/change to make it sort by part number?
and will it also renumber the items/balloons?
also where to put this code/how to show a button to make it work?

Sorry I'm macro/vba/api stupid


-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 4 of 12
Josh_Petitt
in reply to: mcgyvr

Get the .bas that I attached.
Goto Tools=>Macro=>Visual Basic Editor.
On the left hand side there is a project explorer. Select your default.ivb.
RMB on the project and Import File..., select the .bas attached.
Close the VBA Editor.

Open a drawing
RMB on the Inventor toolbar at the top where there is some clear space (not where there is a button)
Select Customize
In the Customize dialog, select the Commands Tab
On the RHS under categories, select Macros
You will probably only have one possible choice, FormatSelectedPartsList, click and hold down on it and drag it to your drawing toolbar. This should create a button on the toolbar.
Now in your drawing, select a parts list, and then while it is still selected, click the macro button.

Let me know if you had any errors or if it worked and I'll try to help.
Message 5 of 12
mcgyvr
in reply to: mcgyvr

Josh,
You ROCK!!
Works like a charm..
1 button click is much better that Autodesk's current method..

boo.. hiss.. to autodesk for not having this standard already.


-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 6 of 12
Anonymous
in reply to: mcgyvr

Ditto! Thanks Josh! That's been pissing me off forever.

wrote in message news:5890487@discussion.autodesk.com...
Josh,
You ROCK!!
Works like a charm..
1 button click is much better that Autodesk's current method..

boo.. hiss.. to autodesk for not having this standard already.
Message 7 of 12
dick_upton
in reply to: Anonymous

Add my voice to the chorus - thank you Josh.

Message 8 of 12
karthur1
in reply to: dick_upton

If there was a way for ilogic to know that there was a change, it should be able to make this happen automatically.

 

 

Message 9 of 12
dick_upton
in reply to: Anonymous

Add my voice to the chorus - thank you Josh.

Message 10 of 12
CadUser46
in reply to: dick_upton

I agree it would be nice to have a setting if you wanted it but this would not be preferable for everyone.  Reason being its easier to update downstream services like ERP if you revise something to add new items at the end rather than distributed somewhere into the existing boms.


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
Message 11 of 12
msklein
in reply to: Josh_Petitt

We throw dash numbers in when there is no drawing no as there is a part no instead and it causes me no end in headaces in sorting as the software wants the dashes before the numbers. i just need it to ignor the dashes. That would be a great option in sorting.

msk

Message 12 of 12
insomnix
in reply to: mcgyvr

I am using the code posted, FormatPartsList, but It does not appear to be doing the renumbering. I execute it using the below code.

 

Dim oPartsList As PartsList
For Each oPartsList In oSheet.PartsLists
    oPartsList.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference (ipartsfileLocation & oMemberFile & ".iam")
    FormatPartsList oPartsList
Next

 

-Inventor 2015, Build: 223, Release: 2015 SP2

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

Post to forums  

Autodesk Design & Make Report