Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 532

Pass parameters to an iLogic Rule

$
0
0

By Adam Nagy

In this article we are accessing iLogicRules from outside and run them using RunRule("componentName", "ruleName"), which does not provide arguments to pass extra information to the Rule. There are other functions though that can be used. They are listed on this help page. In case it moves somewhere else I copy here the info:

Rule arguments

iLogic provides advanced functionality that allows you to pass context information as rule arguments into the rules you run. This information can be used to modify the behavior of a rule without having to create a duplicate rule.

You pass rule arguments using functions available in the IiLogicAutomation interface (for external clients), and in iLogicVB (for other rule code and internal clients). These arguments are made available within a rule via the RuleArguments property.

For IiLogicAutomation, the functions available include:

Function RunRuleWithArguments(
  ByVal doc As Inventor.Document, 
  ByVal ruleName As String, 
  ByVal ruleArguments As Inventor.NameValueMap) As Integer 
Function RunExternalRuleWithArguments(
  ByVal doc As Inventor.Document, ByVal ruleName As String, 
  ByVal ruleArguments As Inventor.NameValueMap) As Integer 
Function RunRuleDirectWithArguments(
  ByVal rule As iLogicRule, 
  ByVal ruleArguments As Inventor.NameValueMap) As Integer

For iLogicVB, the functions available include:

Function RunRule(
  ByVal ruleName As String, 
  ByVal ruleArguments As Inventor.NameValueMap) As Integer 
Function RunRule(
  ByVal compoOrDocName As Object, ByVal ruleName As String, 
  ByVal ruleArguments As Inventor.NameValueMap) As Integer 
Function RunExternalRule(
  ByVal ruleName As String, 
  ByVal ruleArguments As Inventor.NameValueMap) As Integer

Create rule arguments

To create rule arguments, use the Inventor API to create a new NameValueMap object. It is then passed to one of the functions when running the rule.

Access an argument passed to the rule

x = RuleArguments("myArg")

Determine if an argument has been passed to the rule

If RuleArguments.Exists("myArg") Then...

Pass the set of arguments to another rule using RunRule

iLogicVB.RunRule("someOtherRule", RuleArguments.Arguments)

Viewing all articles
Browse latest Browse all 532

Trending Articles