Message 1 of 17

Not applicable
04-06-2018
12:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
If this solved your issue please mark this posting "Accept as Solution".
Or if you like something that was said and it was helpful, Kudos are appreciated. Thanks!!!!
thank you for your answer,
I tried to solve it with the code but i have this error:
Do you have any idea about it?
Thanks
I don't, sorry. I am not an iLogic guru. I can change and dabble with extremely minor lines, but not full blown code.
I know there are others on the forum that get probably get this to work.
If this solved your issue please mark this posting "Accept as Solution".
Or if you like something that was said and it was helpful, Kudos are appreciated. Thanks!!!!
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
Thank you for the code
It wokrs but the problem is that it counts all parts in the assembly, even the invisible parts.
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.
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.
I was refereing to the OP, sorry
Sorry @Anonymous
It doesn't say who you are replying to anymore
Thomas.
OP Opening Post
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
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"
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
thank you very much for the code. It works very good but if i use the filter then it does not work.
Thanks
@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.