No. The AddVbRule technique only works with other local rules, within the same document as the source. The AddVbFile technique works with external iLogic rules as the source. Not just any local or external iLogic rule will work with these techniques either. The source rules have to have the "Straight VB Code" option turned on, and they have to be formatted correctly also.
Here is one of the links which mentions these: https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-32B66838-22E4-4A0A-B5BB-862350C76B36
The source rule (the rule you are referencing) must have that option turned on and formatted completely, but the active rule, which is referencing the other rule, doesn't need to have that option turned on, and isn't nearly as sensitive with the formatting.
Here is a simple example I often refer to demonstrate this functionality:
- Create a new external iLogic rule named "GetFullFileName".
- In your Rule Editor, go to the Options tab, then check the option "Straight VB code".
- Copy and paste the following code into it, then click [Save], (not Save & Run), then [Close].
Class ThisRule
Public Function GetFullFileName(ByRef oDoc As Inventor.Document) As String
If oDoc IsNot Nothing Then
GetFullFileName = oDoc.FullFileName
End If
End Function
End Class
4. Now at the top of a new rule (with no other code in it), copy and paste the following:
AddVbFile "GetFullFileName"
(You could specify the full path and file name with extension, if you wanted, but if your external rules are set up correctly, you don't really need to.)
Once you have pasted (or typed) this into your rule, it should immediately (automatically) be moved into the 'Header' area of the rule. This is OK, and is expected.
5. Now all we have to do is use this function in this new rule to prove it works, so copy and paste the following into your new rule down below (in the regular part of the rule):
MsgBox(GetFullFileName(ThisDoc.Document))
Now we're ready to test this new rule, so click [Save & Run].
It should have just shown you a message with the full path and file name of the document that was active when the new rule was ran.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS
Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)