VBA iLogic Question

VBA iLogic Question

Anonymous
Not applicable
894 Views
4 Replies
Message 1 of 5

VBA iLogic Question

Anonymous
Not applicable

Relatively simple question (hopefully) Long story shorter, I'm using a VBA macro to execute an external iLogic rule in order to create a button on the Inventor Ribbon. During the button creation, it prompts the user for several inputs and stores them as values in iLogic. The iLogic rule then compiles them into a single variable. 

What I need to is somehow pass that single variable (string type) back to VBA, where the iRule was called from, in order to modify it further. Is there code/syntax for this?

0 Likes
Accepted solutions (1)
895 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Have you tried making it a SharedVariable at the end of the External Rule?  SharedVariables are not saved in the file, they are held in memory for other rules to use.  Just remember to SharedVariable.Remove after your done with them.

Or you could create and set the value of an otherwise useless Attribute in an open document within the External Rule, then retrieve its value in the VBA code.

Or you could write the name and value of the variable to an external text file at the end of the Extnal rule, then retrieve that info from that text file and recreate the same variable within the VBA code, after the External rule is called.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

Anonymous
Not applicable

How would I go about the shared variable route? I know how to declare one and close it out in iLogic, but how do I properly call it in VBA?

0 Likes
Message 4 of 5

J-Camper
Advisor
Advisor

I haven't done much with Macros myself, still just doing External rules, but I did find an old Forum Post that might help: https://forums.autodesk.com/t5/inventor-customization/ilogic-pass-an-argument-back-to-calling-rule/t... 

 

After the "solution" Post there is a bit of code that uses SharedVariable to pass Arguments.  Hope this helps.

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Sorry for not getting back with you right away...I've been really busy at work.  The link that @J-Camper posted is a good read for this subject.  It lists yet another way to accomplish what you want.  In the later posts, they simply create a TransientObject called a NameValueMap and added the value they wanted to pass to the other rule to that object.  Like the SharedVariable, it is just held in session memory, so you don't really even need to worry about deleting it or resetting its value to Nothing, as long as you're not planning on calling it again before you restart Inventor.  Any one of these methods would likely work for you.  Let us know if any of these ideas work for you.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes