How to add the total QTY to the parts list?

How to add the total QTY to the parts list?

Anonymous
Not applicable
2,050 Views
16 Replies
Message 1 of 17

How to add the total QTY to the parts list?

Anonymous
Not applicable

Hello,

how can I add the sum of Item QTY to the parts list. 

 

QTY.PNG

 

Thanks

0 Likes
Accepted solutions (1)
2,051 Views
16 Replies
Replies (16)
Message 2 of 17

Cadmanto
Mentor
Mentor

iLogic is the only way I can think of to accomplish this.  See if the attached link offers you some solution.

 

http://adndevblog.typepad.com/manufacturing/2013/12/bom-item-total-quantity-by-sub-assemby.html

 

check.PNGIf this solved your issue please mark this posting "Accept as Solution".

Or if you like something that was said and it was helpful, Kudoskudos.PNG are appreciated. Thanks!!!! Smiley Very Happy

 

New EE Logo.PNG

Inventor.PNG     vault.PNG

Best Regards,
Scott McFadden
(Colossians 3:23-25)


Message 3 of 17

Anonymous
Not applicable

thank you for your answer,

I tried to solve it with the code but i have this error:

 

error.PNG

 

Do you have any idea about it?

Thanks

0 Likes
Message 4 of 17

Cadmanto
Mentor
Mentor

I don't, sorry.  I am not an iLogic guru.  I can change and dabble with extremely minor lines, but not full blown code. Smiley Sad

I know there are others on the forum that get probably get this to work.

 

check.PNGIf this solved your issue please mark this posting "Accept as Solution".

Or if you like something that was said and it was helpful, Kudoskudos.PNG are appreciated. Thanks!!!! Smiley Very Happy

 

New EE Logo.PNG

Inventor.PNG     vault.PNG

Best Regards,
Scott McFadden
(Colossians 3:23-25)


Message 5 of 17

MechMachineMan
Advisor
Advisor

Try this:

 

Sub Main()
	oQTYCol = 2
	
	Dim oDoc As Document
	oDoc = ThisDoc.Document
	
	oSheet = oDoc.ActiveSheet
	
oTotal = 0
For Each oPL In oSheet.PartsLists For Each oRow In oPL.PartsListRows oTotal = CInt(oRow.Item(oQTYCol).Value) + oTotal Next oNewRow = oPL.PartsListRows.Add(0) oNewRow.Item(oQTYCol).Value = oTotal oNewRow.Item(oQTYCol-1).Value = "SUM" Next End Sub

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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 6 of 17

Anonymous
Not applicable

Thank you for the code

It wokrs but the problem is that it counts all parts in the assembly, even the invisible parts.

 

0 Likes
Message 7 of 17

Thomas_Savage
Advisor
Advisor

Hello @kamel9HGBU

 

I have a way to add up the Total QTY without iLogic.

 

I have attached a screencast so you can see how. 

 

In the screencast you can see that i have wrote Total QTY in Category in my iProperties.

 

You need to do this for every part you want to be counted in the Total QTY. So you can pick which ones you want in the Total QTY. 

 

Hope this helps?

 

Thomas.

 

 

 

 



Thomas Savage

Design Engineer


Message 8 of 17

Anonymous
Not applicable

To me it looks like your 1,2,3 line is the sum of the rows above. You don't have 6 parts, you only have 3, no?

0 Likes
Message 9 of 17

Thomas_Savage
Advisor
Advisor

Hello @Anonymous

 

I don't understand what you mean?

 

I do not have 6 parts, or 3. I have 5. So that is 5 Solids in my part. I have attached a screenshot below to show i have 5 Solids in in my assembly.

 

So in the parts list it adds all the Solids that i type Total QTY in Category, which gives to give a Total QTY.

 

Thomas.

 

Total QTY 2.png



Thomas Savage

Design Engineer


0 Likes
Message 10 of 17

Anonymous
Not applicable

I was refereing to the OP, sorry

0 Likes
Message 11 of 17

Thomas_Savage
Advisor
Advisor

Sorry @Anonymous

 

It doesn't say who you are replying to anymore

 

Thomas.



Thomas Savage

Design Engineer


Message 12 of 17

Anonymous
Not applicable

OP Opening Post

0 Likes
Message 13 of 17

MechMachineMan
Advisor
Advisor

A very simple "If" statement fixes that.

 

Sub Main()
	oQTYCol = 2
	
	Dim oDoc As Document
	oDoc = ThisDoc.Document
	
	oSheet = oDoc.ActiveSheet
	
        oTotal = 0

	For Each oPL In oSheet.PartsLists
		For Each oRow In oPL.PartsListRows
If oRow.Visible = True oTotal = CInt(oRow.Item(oQTYCol).Value) + oTotal
End if Next oNewRow = oPL.PartsListRows.Add(0) oNewRow.Item(oQTYCol).Value = oTotal oNewRow.Item(oQTYCol-1).Value = "SUM" Next End Sub 

 


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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 14 of 17

Anonymous
Not applicable

Thank you for your code

It wokrs but when I press on "Save" it adds the "SUM". and if I press one more time it adds "SUM+ old SUM"

sum.PNG

0 Likes
Message 15 of 17

MechMachineMan
Advisor
Advisor
Accepted solution

So only hit save once then...

 

or use the further updated version.

 

Sub Main()
	oQTYCol = 2
	
	Dim oDoc As Document
	oDoc = ThisDoc.Document
	
	oSheet = oDoc.ActiveSheet
	
        oTotal = 0

	For Each oPL In oSheet.PartsLists
		For Each oRow In oPL.PartsListRows
                        If oRow.Visible = True
If oRow.Item(oQtyCol -1).Value = "SUM"
'Do nothing
Else oTotal = CInt(oRow.Item(oQTYCol).Value) + oTotal
End if End if Next
If oPL.PartsListRows.Item(oPL.PartsListRows.Count).Item(oQtyCol -1).Value = "SUM"
oPL.PartsListRows.Item(oPL.PartsListRows.Count).Item(oQtyCol).Value = oTotal
Else
oNewRow = oPL.PartsListRows.Add(0)
oNewRow.Item(oQTYCol).Value = oTotal
oNewRow.Item(oQTYCol-1).Value = "SUM"
End if
Next
End Sub

 


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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 16 of 17

Anonymous
Not applicable

@MechMachineMan

thank you very much for the code. It works very good but if i use the filter then it does not work. 

 

 

 

 

Balloon.PNG

 

Thanks

0 Likes
Message 17 of 17

MechMachineMan
Advisor
Advisor

@Anonymous

 

 The code fails because there is a limitation through the API of not being able to add a partslistrow to a filtered partslist, but you can through the UI* (*Note for @JaneFan or @chandra.shekar.g)

 

However, you also need to make sure the SUM row is not filtered off, so that it will appear visible on your filtered partslist... More specifically, it's because the FILTER applies to all rows.... by using the filter "BALLOONED ITEMS" and not having the "SUM" row ballooned, it will not be excluded from the filter.

 

Therefore, the workaround/solution is to balloon the "SUM" row, and to add the sum row before filtering. To do this:

1. Disable the filter on the PartList then

2.  Run the rule

3. Attach a balloon to any object. (this will be a dummy balloon for the SUM row) Then use attach balloon from list, and attach the "SUM" row. Then remove the balloon number that doesn't correspond with the sum row from that same balloon pair. Then move the "SUM" balloon off page.

4. Apply your filter to the partslist.

5. Run the rule again.


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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type