I don't know if it's much help at this point, but maybe it could save you some trouple in the future.
Below is a simple example of some iLogic code you can use in an external iLogic rule, that will inject a local rule into every reference document of your active assembly document. This example is just adding a little automation into each part file, that causes it to do a document update, then Home the view (same as clicking the home icon above the view cube) after every time the "CUT_LENGTH" parameter changes within that part.
You can replace all the oRuleText with other content as needed for your situation, though.
Instead of looping through each ComponentOccurrence, it only loops through each actual Document being referenced by the assembly. Then it checks to see if this rule already exists within that document. If it does, it asks you if you want to replace its contents with the new contents (oRuleText). If it doesn't exist, it creates it for you.
I put a bunch of extra quoted out lines in there to help explain what is being done.
Dim oRuleName As String = "Update Doc & Home View"
Dim oRuleText As String
oRuleText = _
"oDV = CUT_LENGTH" & vbCrLf &
"InventorVb.DocumentUpdate()" & vbCrLf &
"'Return view to Home View" & vbCrLf &
"ThisApplication.CommandManager.ControlDefinitions.Item(""AppViewCubeHomeCmd"").Execute"
'oDV (above) is just a 'dummy variable', which isn't used for anything.
'It's value though is the name of a Parameter, which is local to that Document,
'so it will trigger the local rule to run any time that specific parameter changes.
'No need to add this rule to an Event Trigger to make this work.
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim iLogicAuto = iLogicVb.Automation
'Dim oRules As IEnumerable
Dim oRule As iLogicRule
Dim oRuleExists As Boolean = False
Dim oRefDoc As Document
For Each oRefDoc In oADoc.AllReferencedDocuments
Try
oRule = iLogicAuto.GetRule(oRefDoc, oRuleName)
oAns = MsgBox("A Rule named '" & oRuleName & "' already exists." & vbCrLf &
"Its Text = " & vbCrLf &
oRule.Text & vbCrLf &
"Do you want to replace its text?", vbYesNo + vbQuestion,"")
If oAns = vbNo Then Return
Catch
oRule = iLogicAuto.AddRule(oRefDoc, oRuleName, "")
End Try
'Setting the rule's text at this point, instead of above,
'causes the rule to not run as soon as it is created.
'If you want the rule to run as soon as it is created,
'put oRuleText where the empty quotes are in the Catch line above.
oRule.Text = oRuleText
iLogicVb.DocumentUpdate
oRefDoc.Save
Next
I hope this helps.
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
- 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
- Create Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here
Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)