Show total mass automatically in Parts list

Show total mass automatically in Parts list

MikeKovacik4928
Advisor Advisor
5,208 Views
16 Replies
Message 1 of 17

Show total mass automatically in Parts list

MikeKovacik4928
Advisor
Advisor

Hi inventor users around the globe & Autodesk employees

 

see jpeg below for details of what I would like to do.

 

IQ_134_Total Weight on BOM_013.jpg Michael Kovacik
2d & 3d Autocad and Inventor designer/draughtsman

Draughting/Designing (Manufacturing) (31 yrs)
-Drawing Board (3 yrs)
--Cad (28 yrs)
---Cadkey (4 yrs)
---AutoCAD 2d & 3d (16 yrs)
---Inventor (4 yrs)
---Autocad and Inventor Simultaneously (4 years)
---(and recently Autocad/Inventor Customisation)

Authorised Autocad & Inventor Professional
Authorised Autodesk Trainer

Higher Diploma Mechanical Engineering
Autodesk Product Design Suite Ultimate 2018
Autocad 2018, Inventor Pro 2018
(personal licensed copy)

Johannesburg, South Africa


(Impossible only means you haven't
found the solution yet)

0 Likes
Accepted solutions (2)
5,209 Views
16 Replies
Replies (16)
Message 2 of 17

mdavis22569
Mentor
Mentor

So you want a total mass option added to the parts list at the bottom? 

 

You have it showing up for each part, which is good, but now you just need that last part?

 

 

 

What about making a virtual part via iLogic calling it Total Mass, giving the weight value of what you have to the assembly you're in ... total mass.

 

 

 


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

---------
Mike Davis

EESignature

Message 3 of 17

MikeKovacik4928
Advisor
Advisor

IQ_134_Total Weight on BOM_015.jpg

Not Solved Yet

My fault

Sorry Michael for not replying

I don't know how to make a virtual part using ilogic, can you explain

Your idea sounds good, I would like to give it a try

 

Mike

 

 

0 Likes
Message 4 of 17

mrattray
Advisor
Advisor

Would it be acceptable to have the total mass displayed somewhere other than your parts list? If you create a text note somewhere on your drawing you can pull up the total mass of your assembly as a linked property. 

https://knowledge.autodesk.com/support/inventor-products/troubleshooting/caas/sfdcarticles/sfdcartic...

Mike (not Matt) Rattray

Message 5 of 17

mdavis22569
Mentor
Mentor

Sorry @MikeKovacik4928 for my delay .... 

 

Have you had a moment to look at or try my suggestion? 

 

I can try it too...


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

---------
Mike Davis

EESignature

0 Likes
Message 6 of 17

MikeKovacik4928
Advisor
Advisor

Thanks Mike

 

No I need it to appear as the bottom of the bom as the last row and automatically add

up the masses of all the parts multiplied by their number of instances.

Something that is quite easily done in excel, just not possible out of the box in Inventor, unfortunately

 

Mike

0 Likes
Message 7 of 17

MikeKovacik4928
Advisor
Advisor

Mike

Not had a chance to try it yet

I don't know how to create a virtual part using illogic.

I will have a look today

 

Mike

0 Likes
Message 8 of 17

MikeKovacik4928
Advisor
Advisor

Mike

Here is how I have done it using virtual component but not using iLogic and filling in things manually. Definitely far from ideal and not automatic.

I would like to take it one step further and automate it using ilogic. However I am new to ilogic and never used it before.

Mike

IQ_134_Total Weight on BOM_027.jpg

IQ_134_Total Weight on BOM_028.jpg

0 Likes
Message 9 of 17

mdavis22569
Mentor
Mentor

Curtis is the iLogic guru ...

 

He might be able to come up with the workflow that would work for that ...

 

 


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

---------
Mike Davis

EESignature

0 Likes
Message 10 of 17

basnederveen
Advocate
Advocate
Accepted solution

Not iLogic, and a different approach. Here's a macro that:

 

- asks you to pick an assembly view

- adds row to partslist (assumes there is only one in the sheet)

- puts the assembly mass in the last row

- if there is already a row with total mass in the parts list, it updates the mass

 

You might have to change the numbers 3 and 4, these are the column numbers. 

 

 

Sub testTotalMass()

Dim dwg As DrawingDocument
Set dwg = ThisApplication.ActiveDocument

Dim oview As DrawingView
Set oview = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Pick the assembly view")

On Error Resume Next
Dim asm As AssemblyDocument
Set asm = oview.ReferencedDocumentDescriptor.ReferencedDocument
If Err Then
    MsgBox ("Not an assembly")
    Exit Sub
End If

Dim pl As PartsList
Set pl = dwg.ActiveSheet.PartsLists.Item(1)

Dim plr As PartsListRow
Dim found As Boolean
For Each plr In pl.PartsListRows
    If plr.Item(3).Value = "TOTAL MASS" Then
        found = True
        Exit For
    End If
Next

Dim txn As Transaction
Set txn = ThisApplication.TransactionManager.StartTransaction(dwg, "Add total mass")

If found = False Then Set plr = pl.PartsListRows.Add(pl.PartsListRows.count, False)

plr.Item(3).Value = "TOTAL MASS"
plr.Item(4).Value = Round(asm.ComponentDefinition.MassProperties.mass, 2) & " kg"

txn.End

End Sub

 

Message 11 of 17

MikeKovacik4928
Advisor
Advisor

basnerdeveen

Thanks

1. How do I load this

2. How do I run it

 

Mike

0 Likes
Message 12 of 17

basnederveen
Advocate
Advocate
Accepted solution

Press Alt + F11 -> paste the code in a module -> create a shortcut by right clicking the ribbon -> customize user commands -> choose 'macros' in the dropdown -> pick the macro you just added -> press the button

 

 

Message 13 of 17

MikeKovacik4928
Advisor
Advisor

Basnederveen

 

Thanks

Works beautifully

 

Mike

0 Likes
Message 14 of 17

anoor
Enthusiast
Enthusiast

Michael,

After you create your B.O.M., you'll need to do the following:

- Select column chooser in top left corner

- Select New Property and Name it 'Total Mass'

- Add it to your selected properties

- Click 'OK', then right click the 'Total Mass' column and select 'Format Column'

- Click the substitution tab and select 'Enable Value Substition'

- Click the drop down menu and select the 'MASS' property

- Under 'When rows are merged, value used is' drop down menu, select 'Sum of Values'

You can follow these steps for each bill you create, or you can follow these steps in your styles editor for your template file and it will show up automatically when you place a B.O.M. on the drawing.

Column Chooser.jpgFormat Column.jpgParts List.jpg

Message 15 of 17

claudio.ibarra
Advocate
Advocate

What are the advantages/disadvantages to putting the code in Modules after hitting Alt+F11 vs putting the same code in iLogic rules?

0 Likes
Message 16 of 17

EMVC
Advocate
Advocate

Hello

 

is i possible to get partname in Partslist table(Title) in this macro se also pisture

 

Sub testTotalMass()

Dim dwg As DrawingDocument
Set dwg = ThisApplication.ActiveDocument

Dim oview As DrawingView
Set oview = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Pick the assembly view")

On Error Resume Next
Dim asm As AssemblyDocument
Set asm = oview.ReferencedDocumentDescriptor.ReferencedDocument
If Err Then
    MsgBox ("Not an assembly")
    Exit Sub
End If

Dim pl As PartsList
Set pl = dwg.ActiveSheet.PartsLists.Item(1)

Dim plr As PartsListRow
Dim found As Boolean
For Each plr In pl.PartsListRows
    If plr.Item(3).Value = "TOTAL MASS" Then
        found = True
        Exit For
    End If
Next

Dim txn As Transaction
Set txn = ThisApplication.TransactionManager.StartTransaction(dwg, "Add total mass")

If found = False Then Set plr = pl.PartsListRows.Add(pl.PartsListRows.count, False)

plr.Item(3).Value = "TOTAL MASS"
plr.Item(4).Value = Round(asm.ComponentDefinition.MassProperties.mass, 2) & " kg"

txn.End

End SubTitle.JPG
Message 17 of 17

jeffi
Observer
Observer

Is there any way to add this logic if I have multiple assemblies on one drawing?

 

When I run the macro on the second assembly, it adds another Total Weight to the first BOM. Also, the summation is not correct. The total weight should be 44.2 and it shows up as 20.0.

 

Jeff I.

 

0 Likes