Weights from assembly

Weights from assembly

baliasM74U3
Advocate Advocate
2,922 Views
16 Replies
Message 1 of 17

Weights from assembly

baliasM74U3
Advocate
Advocate

HI Experts

Inv 2018

 

I have an assembly with 15 components. Can I select 5 of them and find out the mass of these items (combined mass of  components only)from the assembly environment ?

2,923 Views
16 Replies
Replies (16)
Message 2 of 17

SharkDesign
Mentor
Mentor

Don't think so. 

Couple of options. 

 

Open BOM, add the mass column. Copy these into excel and do a sum. 

 

Or

 

Create a new assembly, click the 'restore layout' icon next to the cross in the top right. This tiles the windows. Drag those parts from the browser in to the new assembly and check the mass in the iproperties. 

  Inventor Certified Professional
Message 3 of 17

johan.degreef
Advisor
Advisor

@baliasM74U3 

@SharkDesign 

Set all the parts you don't want to "BOM structure - Reference" and check the mass again.

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
Message 4 of 17

andrewiv
Advisor
Advisor

You could create a level of detail and suppress everything except the 5 components that you want to get the weight of.  When you perform a mass properties update it will ask if you want to calculate the mass of the master LOD.  You can click NO and it will tell you the mass of just the components that are not suppressed.

Andrew In’t Veld
Designer / CAD Administrator

Message 5 of 17

SharkDesign
Mentor
Mentor

If you're doing any of the methods above involving suppressing or referencing stuff do the following. 

 

Click the items you want, click the filter and choose invert selection, then all the items you don't want are now selected. 

You can now suppress en masse or reference.

 

jameswillo_0-1625054693465.png

 

  Inventor Certified Professional
Message 6 of 17

johnsonshiue
Community Manager
Community Manager

Hii! All above suggestions make sense. They are the only ways to do it in Inventor unfortunately. But, strictly speaking they are not what the OP was looking for. Any of the above workflow involves design change. What OP was looking for is a quick way to tell the mass prop of a group of components. The ability is available on Fusion 360.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 7 of 17

karthur1
Mentor
Mentor

@johnsonshiue wrote:

Hii! All above suggestions make sense. ..... The ability is available on Fusion 360.

Many thanks!


😞 😞  Too bad Inventor does not have the same tool for this.

 

 

Message 8 of 17

Curtis_Waguespack
Consultant
Consultant

Hi @baliasM74U3 

 

You can give this ilogic rule a try.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 


oConversion = 1
oUnit = " kg"

' 'uncomment this To use lbs
'oConversion = 2.2046
'oUnit = " lbs mass"

Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oTotalMass As Double

Dim oList As New ArrayList

oSet = oADoc.CreateHighlightSet

While True
	oMsg = "Select parts (press ESC to continue) Total Mass " & _
	Round(oTotalMass * oConversion, 3) & oUnit
	Dim oOcc As ComponentOccurrence
	oOcc = ThisApplication.CommandManager.Pick(
	SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, oMsg)

	' If nothing gets selected then we're done	
	If IsNothing(oOcc) Then Exit While

	'check against list to prevent 
	'selecting same component twice
	If oList.Contains(oOcc.Name) = False Then
		oList.Add(oOcc.Name)
		oSet.AddItem(oOcc)

		Dim oMassProps As MassProperties
		oMassProps = oOcc.Definition.Document.ComponentDefinition.MassProperties
		oTotalMass = oTotalMass + oMassProps.Mass
	End If

End While

InputBox("Total mass in " & oUnit, "ilogic", Round(oTotalMass * oConversion, 3))

oSet.Clear




EESignature

Message 9 of 17

karthur1
Mentor
Mentor

Curtis, 

Sweet!  One thing I noticed is that if the assembly consists of both parts and assemblies, when you try to pick the items from the graphics window, it will only select "parts".  If you want to select the whole sub-assembly, you have to select this from the model browser rather then the graphics window. If you try to select all the items of a sub-assy from the graphics window, it can be difficult to include all the items.  There is no selection widow, but being able to select the entire sub from the model browser is key. 

 

Also, there is no way to remove an item from the selection set.  Pick your items carefully.

 

Kirk

 

Kirk

Message 10 of 17

Curtis_Waguespack
Consultant
Consultant

@karthur1 wrote:

One thing I noticed ...


Hey that's 2 things! 😏

 

Thing 1:

So... I don't know how to allow the user to switch between selecting subassemblies and parts using the Pick method with iLogic... there might be a clever way to code that, but I've never figured it out...

 

the previous example was set to filter for "leaf occurrences" meaning it allowed the user to select parts from within the sub assemblies...  this example is filtering for "occurrences"... so it selects the entire subassembly

 

...but as far as I know it's an either/or choice as far as coding it

 

Thing 2: 

This version removes a previously selected item, if it is selected again.... whereas the previous version simply disallowed it to be selected again.

 

Thing3 (bonus):

I changed the "feedback" to use the client graphics rather than the cursor tool tip, so you should see the weight and number of selected components in the top left of the screen, something like the image below... let me know if that doesn't display well... I've only experimented with using client graphics for this kind of thing in the past, so I don't know how well it translates to different monitor and display setups

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Curtis_W_0-1625149488700.png

 

 

 

 

 

Sub main

	oConversion = 1
	oUnit = " kg"

	'	'uncomment this to use lbs
	'	oConversion = 2.2046
	'	oUnit = " lbs mass"

	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oTotalMass As Double

	Dim oList As New ArrayList

	oSet = oDoc.CreateHighlightSet

	Dim oCollection As ObjectCollection
	oCollection = ThisApplication.TransientObjects.CreateObjectCollection

	While True
		oMsg = "Select components (press ESC to exit select)"

		Dim oOcc As ComponentOccurrence
		oOcc = ThisApplication.CommandManager.Pick(
		SelectionFilterEnum.kAssemblyOccurrenceFilter, oMsg)

		' If nothing gets selected then we're done	
		If IsNothing(oOcc) Then Exit While

		Dim oMassProps As MassProperties
		oMassProps = oOcc.Definition.Document.ComponentDefinition.MassProperties

		'check against list to prevent 
		'selecting same component twice
		If oList.Contains(oOcc.Name) = False Then
			oList.Add(oOcc.Name)
			oCollection.Add(oOcc)
			oTotalMass = oTotalMass + oMassProps.Mass

		Else
			oList.Remove(oOcc.Name)
			oCollection.RemoveByObject(oOcc)
			oTotalMass = oTotalMass - oMassProps.Mass

		End If

		oLine1 = Round(oTotalMass * oConversion, 3) & oUnit _
			& " ; " & oCollection.Count & " items selected"
		Call WriteClientGraphics(oLine1)
		oSet.AddMultipleItems(oCollection)

	End While

	Call ClearGraphics

End Sub

Sub WriteClientGraphics(oLine1 As String)
	oFont = "Stylus BT"
	oFontSize = 35

	Dim oDoc As Document = ThisApplication.ActiveDocument

	' a reference to the component definition.
	Dim oCompDef As ComponentDefinition

	oCompDef = oDoc.ComponentDefinition

	Call ClearGraphics

	oClientGraphics = oCompDef.ClientGraphicsCollection.Add("Text Test")

	Dim oTG As TransientGeometry
	oTG = ThisApplication.TransientGeometry

	Dim oAnchorPoint As Point
	oAnchorPoint = oTG.CreatePoint(0, 1, 1)

	' Create a graphics node.
	Dim oNode As GraphicsNode
	oNode = oClientGraphics.AddNode(1)

	'[ Text1
	Dim oTextGraphics1 As TextGraphics
	oTextGraphics1 = oNode.AddTextGraphics
	oTextGraphics1.Text = oLine1

	' Set the text's anchor in model space.
	oTextGraphics1.Anchor = oAnchorPoint

	' Anchor the text graphics in the view.
	Call oTextGraphics1.SetViewSpaceAnchor( _
	oAnchorPoint, oTG.CreatePoint2d(40, 40), kTopLeftViewCorner)


	oTextGraphics1.Font = oFont
	oTextGraphics1.FontSize = oFontSize
	oTextGraphics1.PutTextColor(0, 0, 255)
	ThisApplication.ActiveView.Update
	']



End Sub

Function ClearGraphics
	' a reference to the component definition.
	Dim oCompDef As ComponentDefinition
	oCompDef = ThisApplication.ActiveDocument.ComponentDefinition

	' Attempt to get the existing client graphics object.  If it exists
	' delete it so the rest of the code can continue as if it never existed.
	Dim oClientGraphics As ClientGraphics
	On Error Resume Next
	oClientGraphics = oCompDef.ClientGraphicsCollection.Item("Text Test")
	If Err.Number = 0 Then
		oClientGraphics.Delete
	End If
	On Error GoTo 0
	ThisApplication.ActiveView.Update
End Function

 

 

EESignature

Message 11 of 17

karthur1
Mentor
Mentor

@Curtis_Waguespack wrote:

@karthur1 wrote:

One thing I noticed ...


Hey that's 2 things! 😏

 

Thing 1:

So... I don't know how to allow the user to switch between selecting subassemblies and parts using the Pick method with iLogic... there might be a clever way to code that, but I've never figured it out...

 

the previous example was set to filter for "leaf occurrences" meaning it allowed the user to select parts from within the sub assemblies...  this example is filtering for "occurrences"... so it selects the entire subassembly

 

...but as far as I know it's an either/or choice as far as coding it

 

Thing 2: 

This version removes a previously selected item, if it is selected again.... whereas the previous version simply disallowed it to be selected again.

 

Thing3 (bonus):

I changed the "feedback" to use the client graphics rather than the cursor tool tip, so you should see the weight and number of selected components in the top left of the screen, something like the image below... let me know if that doesn't display well... I've only experimented with using client graphics for this kind of thing in the past, so I don't know how well it translates to different monitor and display setups

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 


Two things... yea, you know engineers cant add. 😁

 

Thing 1:  If figured that it was "either/ or".  I sort of liked the way it was originally, where we could pick single items from the graphics window, but if needed I could pick an assembly from the browser.  That would give me all the items in the sub.  That way you could have both.

Thing 2:  Excellent.  Much better!!!

Thing 3:  I like it. But if the background is the same color as your text, it might be difficult to see.

 

Kirk

 

Message 12 of 17

Curtis_Waguespack
Consultant
Consultant

ok, so here's a version that has some option that can be uncommented for selection and graphics colors, etc... this way folks can set the "things" up as they prefer. 🙂

 

 

Sub main
	
	'/////////// options
	
	oConversion = 1
	oUnit = " kg"

	'''uncomment these 2 lines to use lbs
	'	oConversion = 2.2046
	'	oUnit = " lbs mass"
	
	Dim oSelectionFilter As SelectionFilterEnum
	'subassembly selection
	oSelectionFilter = SelectionFilterEnum.kAssemblyOccurrenceFilter
	
	'''uncomment this line to use part selection
	'oSelectionFilter = SelectionFilterEnum.kAssemblyLeafOccurrenceFilter
	
	''' uncomment or change this to a named color scheme of your choice
	oColorScheme = "Light"	
	'oColorScheme = "Sky"
	
	Dim oColor As Color
    oColor = ThisApplication.TransientObjects.CreateColor(0, 0, 0) 'black
	
	'''uncomment one of these to change text color
	''' or create your own RGB color values
	'oColor = ThisApplication.TransientObjects.CreateColor(255, 0, 0) 'red
	'oColor = ThisApplication.TransientObjects.CreateColor(0, 255, 0) 'green
	'oColor = ThisApplication.TransientObjects.CreateColor(0, 0, 255) 'blue
	
	
	'/////////// end options

	oCurrentBackground = ThisApplication.ColorSchemes.BackgroundType
	oCurrentBGName = ThisApplication.ActiveColorScheme.Name

	ThisApplication.ColorSchemes.BackgroundType = BackgroundTypeEnum.kOneColorBackgroundType
	ThisApplication.ColorSchemes(oColorScheme).Activate

	On Error GoTo ResetColors
	

	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oTotalMass As Double

	Dim oList As New ArrayList

	oSet = oDoc.CreateHighlightSet

	Dim oCollection As ObjectCollection
	oCollection = ThisApplication.TransientObjects.CreateObjectCollection

	While True
		oMsg = "Select components (press ESC to exit select)"

		Dim oOcc As ComponentOccurrence
		oOcc = ThisApplication.CommandManager.Pick(
		oSelectionFilter, oMsg)

		' If nothing gets selected then we're done	
		If IsNothing(oOcc) Then Exit While

		Dim oMassProps As MassProperties
		oMassProps = oOcc.Definition.Document.ComponentDefinition.MassProperties

		'check against list to prevent 
		'selecting same component twice
		If oList.Contains(oOcc.Name) = False Then
			oList.Add(oOcc.Name)
			oCollection.Add(oOcc)
			oTotalMass = oTotalMass + oMassProps.Mass

		Else
			oList.Remove(oOcc.Name)
			oCollection.RemoveByObject(oOcc)
			oTotalMass = oTotalMass - oMassProps.Mass

		End If

		oLine1 = Round(oTotalMass * oConversion, 3) & oUnit _
		& " ; " & oCollection.Count & " items selected"
		Call WriteClientGraphics(oLine1,oColor)
		oSet.AddMultipleItems(oCollection)

	End While

	Call ClearGraphics
	
	ResetColors :

	ThisApplication.ColorSchemes.BackgroundType = oCurrentBackground
	ThisApplication.ColorSchemes(oCurrentBGName).Activate

End Sub

Sub WriteClientGraphics(oLine1 As String, oColor As Color)
	oFont = "Stylus BT"
	oFontSize = 35

	Dim oDoc As Document = ThisApplication.ActiveDocument

	' a reference to the component definition.
	Dim oCompDef As ComponentDefinition

	oCompDef = oDoc.ComponentDefinition

	Call ClearGraphics

	oClientGraphics = oCompDef.ClientGraphicsCollection.Add("Text Test")

	Dim oTG As TransientGeometry
	oTG = ThisApplication.TransientGeometry

	Dim oAnchorPoint As Point
	oAnchorPoint = oTG.CreatePoint(0, 1, 1)

	' Create a graphics node.
	Dim oNode As GraphicsNode
	oNode = oClientGraphics.AddNode(1)

	'[ Text1
	Dim oTextGraphics1 As TextGraphics
	oTextGraphics1 = oNode.AddTextGraphics
	oTextGraphics1.Text = oLine1

	' Set the text's anchor in model space.
	oTextGraphics1.Anchor = oAnchorPoint

	' Anchor the text graphics in the view.
	Call oTextGraphics1.SetViewSpaceAnchor( _
	oAnchorPoint, oTG.CreatePoint2d(40, 40), kTopLeftViewCorner)


	oTextGraphics1.Font = oFont
	oTextGraphics1.FontSize = oFontSize

	oTextGraphics1.PutTextColor(oColor.Red, oColor.Green, oColor.Blue)
	ThisApplication.ActiveView.Update
	']



End Sub

Function ClearGraphics
	' a reference to the component definition.
	Dim oCompDef As ComponentDefinition
	oCompDef = ThisApplication.ActiveDocument.ComponentDefinition

	' Attempt to get the existing client graphics object.  If it exists
	' delete it so the rest of the code can continue as if it never existed.
	Dim oClientGraphics As ClientGraphics
	On Error Resume Next
	oClientGraphics = oCompDef.ClientGraphicsCollection.Item("Text Test")
	If Err.Number = 0 Then
		oClientGraphics.Delete
	End If
	On Error GoTo 0
	ThisApplication.ActiveView.Update
End Function

 

 

EESignature

0 Likes
Message 13 of 17

karthur1
Mentor
Mentor

I get this for the latest version.  Could not figure out where the error was.

 

karthur1_0-1625155216153.png

 

 

0 Likes
Message 14 of 17

Curtis_Waguespack
Consultant
Consultant

hmmmm...I'm not sure, but it was probably something related to toggling the color schemes... but there might be some hiccups with using the client graphics that I'm not familiar with, since I've not used that all that much

 

here's two other versions....

 

  • a simpler version that just uses the tool tip and gets rid of all the color scheme and client graphics stuff
  • and one that gets rid of all the color scheme stuff, and just writes the info to the tool tip and client graphics both

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

version that just uses tool tip 

Sub main

	'/////////// options

	Dim oSelectionFilter As SelectionFilterEnum
	'subassembly selection
	oSelectionFilter = SelectionFilterEnum.kAssemblyOccurrenceFilter

	'''uncomment this line to use part selection
	'oSelectionFilter = SelectionFilterEnum.kAssemblyLeafOccurrenceFilter	

	oConversion = 1
	oUnit = " kg"

	'''uncomment these 2 lines to use lbs
	'	oConversion = 2.2046
	'	oUnit = " lbs mass"

	'/////////// end options

	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oTotalMass As Double

	Dim oList As New ArrayList

	oSet = oDoc.CreateHighlightSet

	Dim oCollection As ObjectCollection
	oCollection = ThisApplication.TransientObjects.CreateObjectCollection

	oMsg = "Select a component (press ESC to end selection)"
	While True

		Dim oOcc As ComponentOccurrence
		oOcc = ThisApplication.CommandManager.Pick(
		oSelectionFilter, oMsg)

		' If nothing gets selected then we're done	
		If IsNothing(oOcc) Then Exit While

		Dim oMassProps As MassProperties
		oMassProps = oOcc.Definition.Document.ComponentDefinition.MassProperties

		'check against list to prevent 
		'selecting same component twice
		If oList.Contains(oOcc.Name) = False Then
			oList.Add(oOcc.Name)
			oCollection.Add(oOcc)
			oTotalMass = oTotalMass + oMassProps.Mass

		Else
			oList.Remove(oOcc.Name)
			oCollection.RemoveByObject(oOcc)
			oTotalMass = oTotalMass - oMassProps.Mass

		End If

		oMsg = Round(oTotalMass * oConversion, 3) & oUnit _
		& " ; " & oCollection.Count & " items selected"


		oSet.AddMultipleItems(oCollection)

	End While

	InputBox("Total mass in " & oUnit, "ilogic", Round(oTotalMass * oConversion, 3))

	oSet.Clear


End Sub

 

version that uses client graphics

Sub main

	'/////////// options

	Dim oSelectionFilter As SelectionFilterEnum
	'subassembly selection
	oSelectionFilter = SelectionFilterEnum.kAssemblyOccurrenceFilter

	'''uncomment this line to use part selection
	'oSelectionFilter = SelectionFilterEnum.kAssemblyLeafOccurrenceFilter	
	
	oConversion = 1
	oUnit = " kg"

	'''uncomment these 2 lines to use lbs
	'	oConversion = 2.2046
	'	oUnit = " lbs mass"

	'/////////// end options

	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oTotalMass As Double

	Dim oList As New ArrayList

	oSet = oDoc.CreateHighlightSet

	Dim oCollection As ObjectCollection
	oCollection = ThisApplication.TransientObjects.CreateObjectCollection
	
	oMsg = "Select a component (press ESC to end selection)"
	While True
		
		Dim oOcc As ComponentOccurrence
		oOcc = ThisApplication.CommandManager.Pick(
		oSelectionFilter, oMsg)

		' If nothing gets selected then we're done	
		If IsNothing(oOcc) Then Exit While

		Dim oMassProps As MassProperties
		oMassProps = oOcc.Definition.Document.ComponentDefinition.MassProperties

		'check against list to prevent 
		'selecting same component twice
		If oList.Contains(oOcc.Name) = False Then
			oList.Add(oOcc.Name)
			oCollection.Add(oOcc)
			oTotalMass = oTotalMass + oMassProps.Mass

		Else
			oList.Remove(oOcc.Name)
			oCollection.RemoveByObject(oOcc)
			oTotalMass = oTotalMass - oMassProps.Mass

		End If

		oMsg = Round(oTotalMass * oConversion, 3) & oUnit _
		& " ; " & oCollection.Count & " items selected"
		
		Call WriteClientGraphics(oMsg)
		oSet.AddMultipleItems(oCollection)

	End While

	Call ClearGraphics


End Sub

Sub WriteClientGraphics(oLine1 As String)
	oFont = "Stylus BT"
	oFontSize = 35

	Dim oDoc As Document = ThisApplication.ActiveDocument

	' a reference to the component definition.
	Dim oCompDef As ComponentDefinition

	oCompDef = oDoc.ComponentDefinition

	Call ClearGraphics

	oClientGraphics = oCompDef.ClientGraphicsCollection.Add("Text Test")

	Dim oTG As TransientGeometry
	oTG = ThisApplication.TransientGeometry

	Dim oAnchorPoint As Point
	oAnchorPoint = oTG.CreatePoint(0, 1, 1)

	' Create a graphics node.
	Dim oNode As GraphicsNode
	oNode = oClientGraphics.AddNode(1)

	'[ Text1
	Dim oTextGraphics1 As TextGraphics
	oTextGraphics1 = oNode.AddTextGraphics
	oTextGraphics1.Text = oLine1

	' Set the text's anchor in model space.
	oTextGraphics1.Anchor = oAnchorPoint

	' Anchor the text graphics in the view.
	Call oTextGraphics1.SetViewSpaceAnchor( _
	oAnchorPoint, oTG.CreatePoint2d(40, 40), kTopLeftViewCorner)


	oTextGraphics1.Font = oFont
	oTextGraphics1.FontSize = oFontSize

	'oTextGraphics1.PutTextColor(0, 0, 0) 'black
	'oTextGraphics1.PutTextColor(255, 0, 0) 'red
	'oTextGraphics1.PutTextColor(0, 255, 0) 'green
	oTextGraphics1.PutTextColor(0, 0, 255) 'blue
	ThisApplication.ActiveView.Update
	']



End Sub

Function ClearGraphics
	' a reference to the component definition.
	Dim oCompDef As ComponentDefinition
	oCompDef = ThisApplication.ActiveDocument.ComponentDefinition

	' Attempt to get the existing client graphics object.  If it exists
	' delete it so the rest of the code can continue as if it never existed.
	Dim oClientGraphics As ClientGraphics
	On Error Resume Next
	oClientGraphics = oCompDef.ClientGraphicsCollection.Item("Text Test")
	If Err.Number = 0 Then
		oClientGraphics.Delete
	End If
	On Error GoTo 0
	ThisApplication.ActiveView.Update
End Function

 

EESignature

Message 15 of 17

karthur1
Mentor
Mentor

I tested both and no errors on either.  I like the one that writes it to the tool tip.... just my preference.

 

Thanks again.

Kirk

 

 

0 Likes
Message 16 of 17

dlekx
Explorer
Explorer

Hi, I got this by reference from another thread.  I tried it and it works well.  Is there a way to have multiple-selection functionality?  (drag mouse and it picks everything in the window, shift-select in the browser window, etc)

 

0 Likes
Message 17 of 17

Cris-Ideas
Advisor
Advisor

Hi,

It depends what is the purpose of your effort.

 

But if you only want a quick info I would suggest as follows:

1) select everything of interest for you (but this can only be components (parts or assemblies) of the top level)

2) Ctrl+C

3) open new assembly file

4) Ctrl+V

5) iProperties -> physical properties

 

This will be faster than playing with LoD and requiring less effort, and also it is easier than changing other parts to reference BOM, and you will not produce errors in your original model.

But if this is a solution for you it depends on what exactly is that you are after.

 

There are also other potential the like trick that come to my mind, but it all depend on the intent.

 

Cris

Cris,
https://simply.engineering