Hello everyone,
I need a help for something that I just can't do it as quick as I would.
I'd like to measure the volume of certain parts on an assembly, for example: my assembly is composed by parts in steel and parts in gold, and I have to measure only the volume of gold parts.
Till Inventor 2021, this was possible doing a level of detail, and it was a quite good solution.
Now with Inventor 2022, the only solution I found is doing a Substitute of my assembly, excluding all the parts I don't need to, which is a little "annoying" and a slow procedure.
Does anyone know a better solution than the one I found?
Thank you!!
Francesco
Solved! Go to Solution.
Hello everyone,
I need a help for something that I just can't do it as quick as I would.
I'd like to measure the volume of certain parts on an assembly, for example: my assembly is composed by parts in steel and parts in gold, and I have to measure only the volume of gold parts.
Till Inventor 2021, this was possible doing a level of detail, and it was a quite good solution.
Now with Inventor 2022, the only solution I found is doing a Substitute of my assembly, excluding all the parts I don't need to, which is a little "annoying" and a slow procedure.
Does anyone know a better solution than the one I found?
Thank you!!
Francesco
Solved! Go to Solution.
Solved by SharkDesign. Go to Solution.
Solved by cadman777. Go to Solution.
You can use the measure command, select your first model, Press the "add to accumulated value", restart the measure (button below), and select the next model and use the "add to accumulated value" again if needed continue repeating this for all you components.
You can use the measure command, select your first model, Press the "add to accumulated value", restart the measure (button below), and select the next model and use the "add to accumulated value" again if needed continue repeating this for all you components.
I would go to the Inventor Customization forum and ask how to code a simple iLogic rule that filters out all BUT the gold parts and finds each of their volumes and then adds them up. Then you can write that to another iProperty and use it in a text label or whatever.
I would go to the Inventor Customization forum and ask how to code a simple iLogic rule that filters out all BUT the gold parts and finds each of their volumes and then adds them up. Then you can write that to another iProperty and use it in a text label or whatever.
Add the Volume column to your BOM.
Click material to order by material.
Copy and paste into excel to add them up.
Add the Volume column to your BOM.
Click material to order by material.
Copy and paste into excel to add them up.
Also, you can create a Summary BOM.
In a drawing PartsList, use the Group Settings and filter 'by Material', then make all rows Invisible except the one related to Material: GOLD (). See attached example.
Also, you can create a Summary BOM.
In a drawing PartsList, use the Group Settings and filter 'by Material', then make all rows Invisible except the one related to Material: GOLD (). See attached example.
Here's my attempt at an iLogic rule to get the total Volume of a certain kind of material:
' This rule totals all the individual part weights of only the material specified
' Based on Curtis W's & Jane Fan's work
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
' Get the assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
' Get all of the parts in the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences
' Iterate through the occurrences and print the Total Volume.
Dim oOcc As ComponentOccurrence
Dim sumTemp As Double = 0 'Start sum variable @ 0 quantity
For Each oOcc In oLeafOccs
Dim oVol As Double = (Round (oOcc.MassProperties.Volume * .000035315, 1)) 'Volume in cubic feet conversion from cc and rounded off
Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name
If oMat = "Concrete" Then 'Filter out all part except 'concrete' material
sumTemp = sumTemp + oVol
End If
Next
MsgBox("The total volume of Concrete is " & sumTemp & " cf")
' Or you can assign the resulting value to one of your iProperties
Here's my attempt at an iLogic rule to get the total Volume of a certain kind of material:
' This rule totals all the individual part weights of only the material specified
' Based on Curtis W's & Jane Fan's work
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
' Get the assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
' Get all of the parts in the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences
' Iterate through the occurrences and print the Total Volume.
Dim oOcc As ComponentOccurrence
Dim sumTemp As Double = 0 'Start sum variable @ 0 quantity
For Each oOcc In oLeafOccs
Dim oVol As Double = (Round (oOcc.MassProperties.Volume * .000035315, 1)) 'Volume in cubic feet conversion from cc and rounded off
Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name
If oMat = "Concrete" Then 'Filter out all part except 'concrete' material
sumTemp = sumTemp + oVol
End If
Next
MsgBox("The total volume of Concrete is " & sumTemp & " cf")
' Or you can assign the resulting value to one of your iProperties
Here's a better version of the iLogic rule that makes it easier to convert different materials to different Imperial units:
' This rule totals all the individual part weights of only the material specified
' Based on Curtis W's & Jane Fan's work
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
' Get the assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
' Get all of the parts in the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences
'******* CONVERSION FACTORS *******
Dim oCCci As Double = .06102 'cubic inches
Dim oCCcf As Double = .000035315 'cubic feet
Dim oCCcy As Double = .00001308 'cubic yards
Dim oCCgal As Double = .00026 'gallons (liquid)
'******* CONVERSION FACTORS *******
'******* USER CUSTOMIZABLE VARIABLES *******
Dim oMatl As String = "Steel, A36" 'Inventor material name
Dim oConFac As Double = oCCci 'Volume conversion factor for material
Dim oRnd As Integer = 2 'Round to right of decimal point
'******* USER CUSTOMIZABLE VARIABLES *******
' Iterate through the occurrences and print the Total Volume.
Dim oOcc As ComponentOccurrence
Dim sumTemp As Double = 0 'Start sum variable @ 0 quantity
For Each oOcc In oLeafOccs 'Look at each and every part
Dim oVol As Double = (Round (oOcc.MassProperties.Volume * oConFac, oRnd)) 'Round volume result
Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name
If oMat = oMatl Then 'Test for material match
sumTemp = sumTemp + oVol 'Add all results
End If
Next
MsgBox("The total volume of '" & oMatl & "' is " & sumTemp & " ci")
Here's a better version of the iLogic rule that makes it easier to convert different materials to different Imperial units:
' This rule totals all the individual part weights of only the material specified
' Based on Curtis W's & Jane Fan's work
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
' Get the assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
' Get all of the parts in the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences
'******* CONVERSION FACTORS *******
Dim oCCci As Double = .06102 'cubic inches
Dim oCCcf As Double = .000035315 'cubic feet
Dim oCCcy As Double = .00001308 'cubic yards
Dim oCCgal As Double = .00026 'gallons (liquid)
'******* CONVERSION FACTORS *******
'******* USER CUSTOMIZABLE VARIABLES *******
Dim oMatl As String = "Steel, A36" 'Inventor material name
Dim oConFac As Double = oCCci 'Volume conversion factor for material
Dim oRnd As Integer = 2 'Round to right of decimal point
'******* USER CUSTOMIZABLE VARIABLES *******
' Iterate through the occurrences and print the Total Volume.
Dim oOcc As ComponentOccurrence
Dim sumTemp As Double = 0 'Start sum variable @ 0 quantity
For Each oOcc In oLeafOccs 'Look at each and every part
Dim oVol As Double = (Round (oOcc.MassProperties.Volume * oConFac, oRnd)) 'Round volume result
Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name
If oMat = oMatl Then 'Test for material match
sumTemp = sumTemp + oVol 'Add all results
End If
Next
MsgBox("The total volume of '" & oMatl & "' is " & sumTemp & " ci")
You could also add something like this to get a list of materials in the document and get the user to choose:
Dim oMatList As New ArrayList For Each oOcc In oLeafOccs 'Look at each and every part Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name If oMatList.contains(oMat) Else oMatList.add(oMat) End If Next MultiValue.List("matlist") = oMatList oChosenMat = InputListBox("Which material do you want?", MultiValue.List("matlist"), oMatList, Title := "Choose", ListName := "Material")
you need to create a text parameter first called "matlist"
You could also add something like this to get a list of materials in the document and get the user to choose:
Dim oMatList As New ArrayList For Each oOcc In oLeafOccs 'Look at each and every part Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name If oMatList.contains(oMat) Else oMatList.add(oMat) End If Next MultiValue.List("matlist") = oMatList oChosenMat = InputListBox("Which material do you want?", MultiValue.List("matlist"), oMatList, Title := "Choose", ListName := "Material")
you need to create a text parameter first called "matlist"
I was thinking of doing that too, but it would have cost me another 3 hours!
Since I'm a novice at coding, it takes me forever to make a macro.
Anyway, great idea.
Brilliant minds think alike!
I was thinking of doing that too, but it would have cost me another 3 hours!
Since I'm a novice at coding, it takes me forever to make a macro.
Anyway, great idea.
Brilliant minds think alike!
Took me 10mins to write it an then 20 minutes to work out why the multilist didn't work haha!
I'm not great at coding either!!
Took me 10mins to write it an then 20 minutes to work out why the multilist didn't work haha!
I'm not great at coding either!!
What about this then?
' This rule totals all the individual part weights of only the material specified ' Compiled by Chris Huminski and James Willoughby, based on Curtis W's & Jane Fan's work ' Get the active assembly. Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument ' Get the assembly component definition. Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition ' Get all of the parts in the assembly. Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences '******* CONVERSION FACTORS ******* Dim oCCci As Double = .06102 Dim oCCcf As Double = .000035315 Dim oCCcy As Double = .00001308 Dim oCCgal As Double = .00026 '******* CONVERSION FACTORS ******* oUnitPick = InputListBox("Units?", {"Cubic Inches","Cubic Feet","Cubic Yards","Gallons"}, "Cubic Inches", Title := "Units", ListName := "Units") Select Case oUnitPick Case = "Cubic Inches" oUnits = oCCci Case = "Cubic Feet" oUnits = oCCcf Case = "Cubic Yards" oUnits = oCCcy Case = "Gallons" oUnits = oCCgal End Select '[******* USER CUSTOMIZABLE VARIABLES ******* 'Dim oMatl As String = "Steel, A36" 'Inventor material name Dim oConFac As Double = oUnits 'Volume conversion factor for material Dim oRnd As Integer = 2 'Round to right of decimal point ']******USER CUSTOMIZABLE VARIABLES ******* Dim oOcc As ComponentOccurrence Dim sumTemp As Double = 0 'Start sum variable @ 0 quantity '[Create a list of materials Dim oMatList As New ArrayList For Each oOcc In oLeafOccs 'Look at each and every part Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name If oMatList.Contains(oMat)'skip duplicate materials Else oMatList.Add(oMat)'add material to array End If Next oChosenMat = InputListBox("Which material do you want?", oMatList, oMatList, Title := "Choose", ListName := "Material") '] '[Iterate through the occurrences and print the Total Volume. For Each oOcc In oLeafOccs 'Look at each and every part Dim oVol As Double = (Round (oOcc.MassProperties.Volume * oConFac, oRnd)) 'Round volume result Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name If oMat = oChosenMat Then 'Test for material match sumTemp = sumTemp + oVol 'Add all results End If Next '] MsgBox("The total volume of '" & oChosenMat & "' is " & sumTemp & " " & oUnitPick)
What about this then?
' This rule totals all the individual part weights of only the material specified ' Compiled by Chris Huminski and James Willoughby, based on Curtis W's & Jane Fan's work ' Get the active assembly. Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument ' Get the assembly component definition. Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition ' Get all of the parts in the assembly. Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences '******* CONVERSION FACTORS ******* Dim oCCci As Double = .06102 Dim oCCcf As Double = .000035315 Dim oCCcy As Double = .00001308 Dim oCCgal As Double = .00026 '******* CONVERSION FACTORS ******* oUnitPick = InputListBox("Units?", {"Cubic Inches","Cubic Feet","Cubic Yards","Gallons"}, "Cubic Inches", Title := "Units", ListName := "Units") Select Case oUnitPick Case = "Cubic Inches" oUnits = oCCci Case = "Cubic Feet" oUnits = oCCcf Case = "Cubic Yards" oUnits = oCCcy Case = "Gallons" oUnits = oCCgal End Select '[******* USER CUSTOMIZABLE VARIABLES ******* 'Dim oMatl As String = "Steel, A36" 'Inventor material name Dim oConFac As Double = oUnits 'Volume conversion factor for material Dim oRnd As Integer = 2 'Round to right of decimal point ']******USER CUSTOMIZABLE VARIABLES ******* Dim oOcc As ComponentOccurrence Dim sumTemp As Double = 0 'Start sum variable @ 0 quantity '[Create a list of materials Dim oMatList As New ArrayList For Each oOcc In oLeafOccs 'Look at each and every part Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name If oMatList.Contains(oMat)'skip duplicate materials Else oMatList.Add(oMat)'add material to array End If Next oChosenMat = InputListBox("Which material do you want?", oMatList, oMatList, Title := "Choose", ListName := "Material") '] '[Iterate through the occurrences and print the Total Volume. For Each oOcc In oLeafOccs 'Look at each and every part Dim oVol As Double = (Round (oOcc.MassProperties.Volume * oConFac, oRnd)) 'Round volume result Dim oMat As String = oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Material").Value 'Get the material name If oMat = oChosenMat Then 'Test for material match sumTemp = sumTemp + oVol 'Add all results End If Next '] MsgBox("The total volume of '" & oChosenMat & "' is " & sumTemp & " " & oUnitPick)
I tried doing that yesterday, but didn't know how.
Spent 3 hours trying things, but just didn't know that I should've used Case to do it.
The thought occurred to me, but I just couldn't figure it out.
Nice job!
I guess if you want to make this a 'Cadillac', you would add code to create the Parameters and check to make sure none exists as an error checking thing. That way nobody has to do anything but press a button.
I tried doing that yesterday, but didn't know how.
Spent 3 hours trying things, but just didn't know that I should've used Case to do it.
The thought occurred to me, but I just couldn't figure it out.
Nice job!
I guess if you want to make this a 'Cadillac', you would add code to create the Parameters and check to make sure none exists as an error checking thing. That way nobody has to do anything but press a button.
Don't need 'case' it's just neater than 'if' statements.
Don't need 'case' it's just neater than 'if' statements.
Yeah, I tried 'If' but didn't quite get it.
Also, I never knew about 'InputListBox' till seeing it now.
I guess that's cuz it didn't exist in 2010, and doesn't work in it either!
I wonder what I could use in 2010?
Maybe a Form in Inventor VBA?
Thing is, I've been trying to do it using a multi-value list in Parameters (2010 has this).
But I just can't figure out how to connect a UI selection listbox with the iLogic variables equated w/the conversion factor number.
Yeah, I tried 'If' but didn't quite get it.
Also, I never knew about 'InputListBox' till seeing it now.
I guess that's cuz it didn't exist in 2010, and doesn't work in it either!
I wonder what I could use in 2010?
Maybe a Form in Inventor VBA?
Thing is, I've been trying to do it using a multi-value list in Parameters (2010 has this).
But I just can't figure out how to connect a UI selection listbox with the iLogic variables equated w/the conversion factor number.
Hello @cadman777,
cool solution, but unfortunately this doesn't work.
The reason may be that in your example, you had just one element in concrete replied N times, while I have several different parts with the same material.
Hello @cadman777,
cool solution, but unfortunately this doesn't work.
The reason may be that in your example, you had just one element in concrete replied N times, while I have several different parts with the same material.
Works fine for me.
Did you double-click on the PartsList to see that all the other parts are listed with total volumes shown?
Note that the 'Wood, Pressure Treated Pine' consists of both 2x6's and 4x4's, so they are different parts with the same Material, so they 'roll-up' just fine the way I showed you how to do it.
Try again, you may find it works for you.
This is how, for many years, I've created a 'Summary BOM' for structural jobs that have many different structural shapes.
It's never failed me.
Works fine for me.
Did you double-click on the PartsList to see that all the other parts are listed with total volumes shown?
Note that the 'Wood, Pressure Treated Pine' consists of both 2x6's and 4x4's, so they are different parts with the same Material, so they 'roll-up' just fine the way I showed you how to do it.
Try again, you may find it works for you.
This is how, for many years, I've created a 'Summary BOM' for structural jobs that have many different structural shapes.
It's never failed me.
Ops! Obviously, in my previous reply I referred to @cadman777 's BOM solution with Group Setting.
Anyway, thank you again @cadman777 and thank you @SharkDesign, this sounds great! Coding is still a mistery for me, and I started to use Inventor not long ago. Probably, I'll search for an iLogic training.
Ops! Obviously, in my previous reply I referred to @cadman777 's BOM solution with Group Setting.
Anyway, thank you again @cadman777 and thank you @SharkDesign, this sounds great! Coding is still a mistery for me, and I started to use Inventor not long ago. Probably, I'll search for an iLogic training.
I take back my comment on InputListBox.
There is one in 2010.
I just needed to change the syntax.
But I'm still not getting to the end result.
It's a mixup between the code and the multi-value lists in Parameters.
I take back my comment on InputListBox.
There is one in 2010.
I just needed to change the syntax.
But I'm still not getting to the end result.
It's a mixup between the code and the multi-value lists in Parameters.
d0 is the value the user eventually chooses
Prompt is just a text string in the pop up
MultiValue.List("d0") - d0 has to be in your parameters box for this to work.
I got around it by deleting the text entirely and just referencing my array list in there. The array list is essentially the same as multivalue parameter but it only lives in the iLogic code.
d0 is the default selected item. Not sure why my code works because I didn't specify this. probably should write oMatList(0) to choose the first item in the list.
The rest are just text in the pop up.
d0 = InputListBox("Prompt", MultiValue.List("d0"), d0, Title := "Title", ListName := "List")
This is where I declared the arraylist
Dim oMatList As New ArrayList
Then the loop below that adds the values to build a list (oMat is the material name for the occurance so it changes every loop)
oMatList.Add(oMat)
One thing that can sometimes cause these loops to crash is if you have weldments in your assembly, so sometimes it's wise to put in a try/catch on the loop.
d0 is the value the user eventually chooses
Prompt is just a text string in the pop up
MultiValue.List("d0") - d0 has to be in your parameters box for this to work.
I got around it by deleting the text entirely and just referencing my array list in there. The array list is essentially the same as multivalue parameter but it only lives in the iLogic code.
d0 is the default selected item. Not sure why my code works because I didn't specify this. probably should write oMatList(0) to choose the first item in the list.
The rest are just text in the pop up.
d0 = InputListBox("Prompt", MultiValue.List("d0"), d0, Title := "Title", ListName := "List")
This is where I declared the arraylist
Dim oMatList As New ArrayList
Then the loop below that adds the values to build a list (oMat is the material name for the occurance so it changes every loop)
oMatList.Add(oMat)
One thing that can sometimes cause these loops to crash is if you have weldments in your assembly, so sometimes it's wise to put in a try/catch on the loop.
Can't find what you're looking for? Ask the community or share your knowledge.