<?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 Re: Creating a Function in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/creating-a-function/m-p/6495556#M66054</link>
    <description>&lt;P&gt;Hi Nick.Steele.205,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quick and dirty example, but try something like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;BR /&gt;Best of luck to you in all of your Inventor pursuits,&lt;BR /&gt;Curtis&lt;BR /&gt;&lt;A href="http://inventortrenches.blogspot.com" target="_blank"&gt;http://inventortrenches.blogspot.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rule1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main

Call Number()

Dim map As Inventor.NameValueMap 
map = ThisApplication.TransientObjects.CreateNameValueMap()

Dim sString As String
map.Add("sString", "Hello World! : " &amp;amp; oNumber)

iLogicVb.RunRule("Rule2",map)


MessageBox.Show(SharedVariable("Foo_Variable"), "iLogic Rule1")

End Sub

Dim oNumber As Integer

Function Number
 
oNumber = 12

End Function&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rule2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim sArg as String
sArg = RuleArguments("sString")
MessageBox.Show(sArg, "iLogic Rule2")

Dim sNonsense As String
sNonsense = "foo"

SharedVariable("Foo_Variable") = sArg &amp;amp; " " &amp;amp; sNonsense

&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Aug 2016 21:42:48 GMT</pubDate>
    <dc:creator>Curtis_Waguespack</dc:creator>
    <dc:date>2016-08-11T21:42:48Z</dc:date>
    <item>
      <title>Creating a Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/creating-a-function/m-p/6495470#M66051</link>
      <description>&lt;P&gt;Here's my setup,&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I have 14&amp;nbsp;rules that all use the same dictionary.&lt;/LI&gt;&lt;LI&gt;I would like to place that dictionary in a rule, and then pass the value i want to lookup in that dictionary to that rule.&lt;/LI&gt;&lt;LI&gt;I would then like the dictionary rule to send the entry back to the main rule&lt;/LI&gt;&lt;LI&gt;I&amp;nbsp;would like the main rule to pull values from that entry&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my current code looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SyntaxEditor Code Snippet&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;WPS&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;New&lt;/SPAN&gt; &lt;SPAN&gt;Dictionary&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Of&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;List&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Of&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;
&lt;BR /&gt;&lt;SPAN&gt;WPS&lt;/SP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lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Weld_G1S_CVNR&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;WPSx&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;11&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody have a tutorial or can provide some help with creating a function that can have varibles passed to and from it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I want to pass the parameter "Weld_G1S_WPS" to the new function and then have that function send the entry back and then it pulls the index value out of the entry. I want to do this because&amp;nbsp;when these dictionary entries change, i want to change it in the code once, rather than in 14 different rules.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 21:07:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/creating-a-function/m-p/6495470#M66051</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-11T21:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/creating-a-function/m-p/6495556#M66054</link>
      <description>&lt;P&gt;Hi Nick.Steele.205,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quick and dirty example, but try something like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;BR /&gt;Best of luck to you in all of your Inventor pursuits,&lt;BR /&gt;Curtis&lt;BR /&gt;&lt;A href="http://inventortrenches.blogspot.com" target="_blank"&gt;http://inventortrenches.blogspot.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rule1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main

Call Number()

Dim map As Inventor.NameValueMap 
map = ThisApplication.TransientObjects.CreateNameValueMap()

Dim sString As String
map.Add("sString", "Hello World! : " &amp;amp; oNumber)

iLogicVb.RunRule("Rule2",map)


MessageBox.Show(SharedVariable("Foo_Variable"), "iLogic Rule1")

End Sub

Dim oNumber As Integer

Function Number
 
oNumber = 12

End Function&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rule2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim sArg as String
sArg = RuleArguments("sString")
MessageBox.Show(sArg, "iLogic Rule2")

Dim sNonsense As String
sNonsense = "foo"

SharedVariable("Foo_Variable") = sArg &amp;amp; " " &amp;amp; sNonsense

&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Aug 2016 21:42:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/creating-a-function/m-p/6495556#M66054</guid>
      <dc:creator>Curtis_Waguespack</dc:creator>
      <dc:date>2016-08-11T21:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/creating-a-function/m-p/6496264#M66072</link>
      <description>&lt;P&gt;Hi Nick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this might helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub sample()
Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument
Dim oFunction As Variant
Dim oAut(1 To 3) As String
Dim tesn As String
    oAut(1) = oDoc.PropertySets("Summary Information").Item("Author").value
    oFunction = TestFunction(oAut(1)) 'Sending parameter to the function
    oAut(2) = oFunction(2) 'getting back one value send by the function TestFunction
    oAut(3) = oFunction(3) 'getting back another value send by the function TestFunction

End Sub
Function TestFunction(oAut As String)
Dim oFunction(2 To 3)
    oFunction(2) = oAut &amp;amp; "2"
    oFunction(3) = oAut &amp;amp; "3"
    TestFunction = oFunction
End Function&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 09:30:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/creating-a-function/m-p/6496264#M66072</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-12T09:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Function</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/creating-a-function/m-p/6496772#M66082</link>
      <description>&lt;P&gt;I can make this work! Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:54:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/creating-a-function/m-p/6496772#M66082</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-12T13:54:29Z</dc:date>
    </item>
  </channel>
</rss>

