If anyone out there could help me I would appreciate it.
I have a custom iProperty in every part that I make ("Fluid Mass"). I have already figured out the iLogic to automatically fill in this iProperty with the correct information. I was wondering if there is a way at the assembly level (using iLogic) to search all parts for this iProperty and add them together? (Similar to the way mass works at the assembly level without iLogic).
An added bonus would be if for some reason any parts in the assembly didn’t have the ("Fluid Mass") iProperty then a message would alert me to which ones needed the iProperty added.
Thank you in advance to anyone that helps.
Solved! Go to Solution.
You will better off posting this in the Inventor Customisation forum instead.
Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Design & Manufacturing Technical Services Manager at Cadpro New Zealand
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project
Hi,
Kindly check the below code, but you have to create custom property in your assembly "Total Fluid Mass".
Option Explicit
Imports Autodesk.Inventor
Sub Main
Dim oApp As Inventor.Application = ThisApplication
Dim oAssy As Inventor.AssemblyDocument = oApp.ActiveDocument
Dim TotalFluidMass As Double = 0
For Each oSubDoc as Inventor.Document in oAssy.AllReferencedDocuments
' Only process if document is a part document
if oSubDoc.DocumentType = kPartDocument then
'Get Custom Properties (User Defined Properties)
Dim oPartPropset As Inventor.PropertySet = oSubDoc.PropertySets("Inventor User Defined Properties")
Try
Dim FluidMass As Double = oPartPropset("Fluid Mass").Value
' Add part Fluid Mass to total Mass
TotalFluidMass += FluidMass
Catch ee As Exception
' Do not raise or display an error. We assume all parts have a "Fluid Mass" custom property
End Try
End If
Next
' Get Master Assembly Custom PropertySet
Dim oAssyPropset As Inventor.PropertySet = oAssy.PropertySets("Inventor User Defined Properties")
Try
' Set Custom Property to total Mass
oAssyPropset("Total Fluid Mass").Value = TotalFluidMass
Catch
' Do not raise or display an error. We assume the Master Assembly has a "Total Fluid Mass" custom property
End Try
oAssyPropset = Nothing
oAssy = Nothing
oApp = Nothing
'Remove the following when doen testing
MessageBox.show(TotalFluidMass.ToString & " TotalFluidMass of parts in the assembly")
End Sub