<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Call external ilogic rule that returns value in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/call-external-ilogic-rule-that-returns-value/m-p/5795566#M58362</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is best practice to call an external rule that returns a value that can be processed by the calling rule?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example: the external rules iterates through all occs in the assembly&lt;/P&gt;&lt;P&gt;all occs are collected in a collection object&lt;/P&gt;&lt;P&gt;The collection object will then be&amp;nbsp;returned to the calling rule&lt;/P&gt;&lt;P&gt;the calling rule will execute logic on the returned collection&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know if an external rule can return values to the calling rule (without using shared variable)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;br martijn&lt;/P&gt;</description>
    <pubDate>Mon, 31 Aug 2015 11:33:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-08-31T11:33:41Z</dc:date>
    <item>
      <title>Call external ilogic rule that returns value</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/call-external-ilogic-rule-that-returns-value/m-p/5795566#M58362</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is best practice to call an external rule that returns a value that can be processed by the calling rule?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example: the external rules iterates through all occs in the assembly&lt;/P&gt;&lt;P&gt;all occs are collected in a collection object&lt;/P&gt;&lt;P&gt;The collection object will then be&amp;nbsp;returned to the calling rule&lt;/P&gt;&lt;P&gt;the calling rule will execute logic on the returned collection&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know if an external rule can return values to the calling rule (without using shared variable)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;br martijn&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2015 11:33:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/call-external-ilogic-rule-that-returns-value/m-p/5795566#M58362</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-31T11:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Call external ilogic rule that returns value</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/call-external-ilogic-rule-that-returns-value/m-p/5795677#M58368</link>
      <description>&lt;P&gt;Hi, I dont think so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;iLogic is set-up to be more of a macro feature - code that can be run, but doesn't return a value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A better bet would to be to set up your program to include multiple subs/functions including the 2nd one you want to use as when you use a function you can return results.&lt;/P&gt;&lt;P&gt;ie;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sub Main() 'Required name and line&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;oNewValue = YourFunction(args,,,) 'Function call line&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; 'Additional functionality here or above&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Function YourFunction(arg1 as type, arg2 as type, ....) ' requires args&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Rule Functionality here&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2015 13:08:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/call-external-ilogic-rule-that-returns-value/m-p/5795677#M58368</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2015-08-31T13:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Call external ilogic rule that returns value</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/call-external-ilogic-rule-that-returns-value/m-p/12150045#M156056</link>
      <description>&lt;P&gt;I know this is old, but seeing as this was a prominent answer in my search I felt I needed to supply an answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes you can.&lt;/P&gt;&lt;P&gt;Search how to send values to an ExternalRule using a NameValueMap.&lt;/P&gt;&lt;P&gt;Dim Map As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You send the value by the following;&lt;/P&gt;&lt;P&gt;Map.Add("NameofValue", Value)&lt;/P&gt;&lt;P&gt;Map.Add("NameofValue2", Value2), etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Call your external Rule via&lt;/P&gt;&lt;P&gt;ilogicVb.RunExternalRule("ExternalRuleName",Map)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the external Rule you access the Map values from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NameofValue = RuleArguments("NameofValue")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To return a new value to the original Rule use the following;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RuleArguments.Arguments.Value("NameofValue") = NewValue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you return to the Calling Rule, use the following;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NewValue =Map.Value("NameofValue")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please exercise caution with copy paste of my code. I typed this in a hurry and nothing was a copy paste from working code. But I hope this will help someone out someday. (Most likely myself if I'm honest)&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 18:15:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/call-external-ilogic-rule-that-returns-value/m-p/12150045#M156056</guid>
      <dc:creator>j3scat</dc:creator>
      <dc:date>2023-08-04T18:15:46Z</dc:date>
    </item>
  </channel>
</rss>

