Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Passing information between VBA Macros and iLogic

2 REPLIES 2
Reply
Message 1 of 3
mbiernackiRVZ4P
248 Views, 2 Replies

Passing information between VBA Macros and iLogic

mbiernackiRVZ4P
Participant
Participant

Hey all, Is there a simple way to pass information between VBA Macros and iLogic? I want to use VBA forms to control my iLogic Rules, since iLogic from are not very easy to work with.

0 Likes

Passing information between VBA Macros and iLogic

Hey all, Is there a simple way to pass information between VBA Macros and iLogic? I want to use VBA forms to control my iLogic Rules, since iLogic from are not very easy to work with.

2 REPLIES 2
Message 2 of 3

Michael.Navara
Advisor
Advisor

This is not the right way. If you want to create your own dialogs, use WinForms instead of VBA forms. VBA is retired and can be removed in future.

See the SDK samples, or posts on this forum for more information how to use WinForms. 

This is not the right way. If you want to create your own dialogs, use WinForms instead of VBA forms. VBA is retired and can be removed in future.

See the SDK samples, or posts on this forum for more information how to use WinForms. 

Message 3 of 3

WCrihfield
Mentor
Mentor

I agree with Michael on this also.  I would advise you to use a 'System.Windows.Forms.Form' instead of a VBA UserForm, because they stopped installing VBA with Inventor back around 2020, due to security issues, partially because Microsoft was no longer maintaining it.

 

But yes, there is a way to 'pass' data between VBA macros and iLogic rules.  How you would do that sort of depends on where the process starts, and where it ends.  If the process starts from a VBA macro, then you would need to create a NameValueMap within that macro, then put data into it that you want to 'send' to the iLogic rule.  Then use one of the lines of code for running an iLogic rule that allows you to supply 'arguments' (the NameValueMap).  Then, the iLogic rule it is running needs to be set-up to receive that data using the iLogic 'RuleArguments' object.  The rule would first need to check if 'any' data was sent to it or not.  If there is some, then it would need to check within the entries of the NameValueMap it received through the RuleArguments object, checking entry names, and value types, and setting those to local variables within the rule, for use later.  Then, if data needs to be sent back to the VBA macro, you will need to put that data into the NameValueMap using the RuleArguments object, before the end of the rule.  Then when control returns to the VBA macro (after the point in its code where it ran that rule), it can check within that same NameValueMap that it created earlier in the macro's code, to check for edited values, or new entries.  It can be a bit complicated to wrap your head around.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

I agree with Michael on this also.  I would advise you to use a 'System.Windows.Forms.Form' instead of a VBA UserForm, because they stopped installing VBA with Inventor back around 2020, due to security issues, partially because Microsoft was no longer maintaining it.

 

But yes, there is a way to 'pass' data between VBA macros and iLogic rules.  How you would do that sort of depends on where the process starts, and where it ends.  If the process starts from a VBA macro, then you would need to create a NameValueMap within that macro, then put data into it that you want to 'send' to the iLogic rule.  Then use one of the lines of code for running an iLogic rule that allows you to supply 'arguments' (the NameValueMap).  Then, the iLogic rule it is running needs to be set-up to receive that data using the iLogic 'RuleArguments' object.  The rule would first need to check if 'any' data was sent to it or not.  If there is some, then it would need to check within the entries of the NameValueMap it received through the RuleArguments object, checking entry names, and value types, and setting those to local variables within the rule, for use later.  Then, if data needs to be sent back to the VBA macro, you will need to put that data into the NameValueMap using the RuleArguments object, before the end of the rule.  Then when control returns to the VBA macro (after the point in its code where it ran that rule), it can check within that same NameValueMap that it created earlier in the macro's code, to check for edited values, or new entries.  It can be a bit complicated to wrap your head around.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report