Sharing information between two external iLogic Rules

Sharing information between two external iLogic Rules

nheinze
Observer Observer
285 Views
3 Replies
Message 1 of 4

Sharing information between two external iLogic Rules

nheinze
Observer
Observer

Hello,

 

I have three external iLogic rules: one to prompt the user for a file location, a second to export an IDW to PDF and a Main rule to call these two rules which create a PDF in the desired location.  (I also have a single rule that successfully does this, but I want to learn how to split it up).

 

When running the Main rule I get the following error: "Access to the path 'PDF' is denied".  I believe the problem is that the first two rules aren't talking to each other, so the second rule doesn't know where to save the file.

 

How can I extract the file location from the first rule to use in the second rule?  I've tried using shared variables with no luck.

 

Can this be done?

 

Thanks,

Nate

0 Likes
286 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant

Hi @nheinze,

Here is one way to do this. Note that if using this method you might need the main rule, since the first rule calls the second rule to run.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
 

 

FilePath Rule

oPath = InputBox("Enter path", "iLogic", "C:\Temp\")

Dim oValueMap As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
oValueMap.Add("FilePath", oPath)

'hand path to other rule
iLogicVb.RunRule("PDF Rule", oValueMap)

 

 

PDF Rule

'path from other rule
oPath = RuleArguments("FilePath")

If oPath = "" Then return 'exit rule

MsgBox("Your PDF will be saved here: " & oPath)

 

EESignature

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

Hi @nheinze.  There are two common ways to share information between iLogic rules.  One way is to use the SharedVariable Interface iLogic snippets (on System side of iLogic Snippets, then under a folder called 'Variables'.  They are temporary variables that are stored in Inventor's session memory, so they will disappear when Inventor is closed.  The other way is to use a NameValueMap and the RuleArguments interface.  Here is a link to one of my contribution posts with an example of sending and receiving data between iLogic rules.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4

Curtis_Waguespack
Consultant
Consultant
@nheinze wrote:

I've tried using shared variables with no luck.

 


 

 

 

To use a Shared Variable it would be something like this

 

Main Rule

iLogicVb.RunExternalRule("FilePath Rule")
iLogicVb.RunExternalRule("PDF Rule")

 

FilePath Rule

oPath = InputBox("Enter path", "iLogic", "C:\Temp\")
SharedVariable("FilePath") = oPath

 

PDF rule

If Not SharedVariable.Exists("FilePath") Then Return 'exit rule
	
oPath = SharedVariable("FilePath")

MsgBox("Your PDF will be saved here: " & oPath)

'clean up shared varaible
SharedVariable.Remove("FilePath")

 

EESignature