I may be able to help you our on ths one. I didn't see the name of your Custom iProperty in which you are storing the alternative Mass, so in my code I used "AltMass" in its place. (I assumed this is a Custom iProperty, instead of a Parameter, due to the first line of your original post.)
This code would be in an external iLogic rule. It would be triggered by a simple local rule (show below).
It basically loops through each ComponentOccurrnece and, based on how its Parameter is set, adds either its "AltMass" or its regular Mass to the main Assembly's "AltMass" custom Property. I hope this is what you were trying to do.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Assembly Documents.",vbOK, "WRONG DOCUMENT TYPE")
Return
End If
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oUParams As UserParameters = oADef.Parameters.UserParameters
Dim oACustMass As UserParameter = oUParams.Item("CustomMass") 'Boolean type
Dim oAMass As Double = iProperties.Mass
Dim oAAltMass As Double = iProperties.Value("Custom","AltMass")
Dim oOccADef As AssemblyComponentDefinition
Dim oOccPDef As PartComponentDefinition
Dim oOccDoc As Document
Dim oOccCustMass As UserParameter
Dim oOccMass As Double
Dim oOccAltMass As Double
Dim oOccs As ComponentOccurrences = oADef.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oOccADef = oOcc.Definition
oOccDoc = oOcc.Definition.Document
oOccCustMass = oOccADef.Parameters.UserParameters.Item("CustomMass")
If oOccCustMass.Value = True Then
'Assuming your Custom iProperty for the manual mass is named "AltMass"
oOccAltMass = oOccDoc.PropertySets.Item("Inventor User Defined Properties").Item("AltMass").Value
oAAltMass = oAAltMass + oOccAltMass
ElseIf oOccCustMass.Value = False Then
oOccMass = oOccDoc.PropertySets.Item("Design Tracking Properties").Item("Mass").Value
oAAltMass = oAAltMass + oOccMass
End If
End If
Next
Your local rule will look like this:
oDV = CustomMass
iLogicVb.RunExternalRule("TheNameOfYourExternalRule")
It will automatically be triggered any time the value of the local "CustomMass" parameter changes.
If need be, I can include some code at the beginning of this external rule that checks for this local rule, and creates it if not found.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.
Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.
- Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
- MessageBox, InputBox, and InputListBox Size & Format Options Click Here
- Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
- Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
- Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
- Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
- SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
- Create DocumentSubTypeEnum Click Here
Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)