<?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: Shared Variable of a structure losing structure &amp;quot;Type&amp;quot; in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10592821#M128405</link>
    <description>&lt;P&gt;Hey&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7289526"&gt;@j.haggenjos&lt;/a&gt;&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking into implementing a similar data structure with external rules. Did you have any luck with resolving this particular challenge, and if so, care to share your findings?&lt;/P&gt;</description>
    <pubDate>Thu, 02 Sep 2021 07:45:15 GMT</pubDate>
    <dc:creator>KarlH_</dc:creator>
    <dc:date>2021-09-02T07:45:15Z</dc:date>
    <item>
      <title>Shared Variable of a structure losing structure "Type"</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/9094597#M102254</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm in the process of coding my first iLogic project. I'm having an issue with a shared variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one rule reading data from a CSV file and puting them into a customer parameter Structure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Structure CustomParam
	Public n As Integer
	Public Name() As String
	Public Values As ArrayList
End Structure&lt;/PRE&gt;&lt;PRE&gt;	Dim oCustomParams As ArrayList
	oCustomParams = ReadParam(oPath)
	SharedVariable("oCustomParams") = oCustomParams
	
	Dim oCustomParam As CustomParam
	oCustomParam = ReadParam(oPath_single)
	SharedVariable("oCustomParam") = oCustomParam&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is transfered to other rules correctly and I can access all the data. Both a single variable and an ArrayList of variables work. My issue is that I can't "call"&amp;nbsp; the structure type anymore.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Sub MySub (oCustomParam As CustomParam)
...
End Sub

Sub MySub (oCustomParam)
...
End Sub&lt;/PRE&gt;&lt;P&gt;The first case will return a "Specified cast is not valid."&lt;BR /&gt;&lt;BR /&gt;Not specifying the argument type will solve the issue. However, I would like if possible to specify the argument as a "CustomParam".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to achieve this? Maybe a Structure is not the proper way to handle this. I don't have much coding experience so I may be looking at this wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your time and answers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 12:13:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/9094597#M102254</guid>
      <dc:creator>j.haggenjos</dc:creator>
      <dc:date>2019-10-18T12:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Variable of a structure losing structure "Type"</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/9098045#M102282</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try it this way!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub main
	Dim s As String = "This"
	MsgBox( main2(s))
End Sub

Public Function main2 (s As String)
	Dim aaa As String = s
	Return aaa
End Function&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2019 08:44:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/9098045#M102282</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2019-10-21T08:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Variable of a structure losing structure "Type"</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/9098813#M102309</link>
      <description>&lt;P&gt;I'm not sure I understand your answer.&amp;nbsp;I don't think I can call function outside the rule in which they are declared.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to share a set of data between two (or more) rules which is why I created a shared variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The transfer work. I'm not losing any data. However, the data type "CustomParam" that I created is lost in the process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 14:42:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/9098813#M102309</guid>
      <dc:creator>j.haggenjos</dc:creator>
      <dc:date>2019-10-21T14:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Variable of a structure losing structure "Type"</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10592821#M128405</link>
      <description>&lt;P&gt;Hey&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7289526"&gt;@j.haggenjos&lt;/a&gt;&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking into implementing a similar data structure with external rules. Did you have any luck with resolving this particular challenge, and if so, care to share your findings?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 07:45:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10592821#M128405</guid>
      <dc:creator>KarlH_</dc:creator>
      <dc:date>2021-09-02T07:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Variable of a structure losing structure "Type"</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10672649#M129746</link>
      <description>&lt;P&gt;Hey &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10960304"&gt;@KarlH_&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the delay in my answer. I only see your post now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ended up accepting that Shared Variable are undefined object. You can put anything in it and read it in other rules. But I never managed to cast it to a specific type. As long as you are aware of it in your code, you can do pretty much any data transfer between two rules.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have since then moved to an Inventor AddIn which gives me greater control over what is happening. However, this limitation of Shared Variable was not the reason to move to an AddIn.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 10:19:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10672649#M129746</guid>
      <dc:creator>j.haggenjos</dc:creator>
      <dc:date>2021-10-07T10:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Variable of a structure losing structure "Type"</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10672789#M129751</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7289526"&gt;@j.haggenjos&lt;/a&gt;.&amp;nbsp; There is actually a workflow for doing what you want with iLogic rules, it's just not discussed very much here on the forums for some reason.&amp;nbsp; You can actually build up your own sets of regularly used Public Subs, Functions, Enums, etc., as iLogic rules (as long as they are formatted correctly and have the right settings turned on).&amp;nbsp; Then you can have access to the resources in those other rules by including a special type of reference to those other rule(s) at the top of your new rule.&lt;/P&gt;
&lt;P&gt;Here is a link to one online help page that touches on the subject.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-32B66838-22E4-4A0A-B5BB-862350C76B36" target="_blank" rel="noopener"&gt;Advanced iLogic Techniques Reference&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp; In order to prepare an 'external' rule to be used as a reference for resources like this, you first need to more thoroughly prepare/format the code within, similarly to how it might be laid out in regular vb.net, with everything contained within Classes &amp;amp;/or Modules.&amp;nbsp; Then in the Option panel of the iLogic Rule Editor for that rule, turn on the 'Straight VB Code' setting.&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp; Then in the new rule (where you want to use a resource from that first rule), either use the AddVBRule followed by the quoted name of the other rule, at the top of the rule, or use the AddVBFile, followed by the quoted path &amp;amp; name of the file to reference code from at the top of the rule.&lt;/P&gt;
&lt;P&gt;It can be a bit difficult to get working properly if you're new to programming, because all the usual iLogic snippet type codes won't work like normal within that resource rule, due to how it has to be formatted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN style="background-color: green; color: white;"&gt;&lt;STRONG&gt;ACCEPT SOLUTION&lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7401B55A0A518861312A0F851CD29320/emoticons/1f44d.png" alt=":thumbs_up:" title=":thumbs_up:" /&gt;.&lt;/P&gt;
&lt;P&gt;If you want and have time, I would appreciate your Vote(s) for &lt;A href="https://forums.autodesk.com/t5/forums/recentpostspage/post-type/message/interaction-style/idea/user-id/7812054/" target="_blank"&gt;My IDEAS &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B166FEBB95D67CFA84899D32D8E17FC1/emoticons/1f4a1.png" alt=":light_bulb:" title=":light_bulb:" /&gt;&lt;/A&gt; or you can Explore &lt;A href="https://knowledge.autodesk.com/profile/LTSUSR7HXMSAE/articles" target="_blank"&gt;My CONTRIBUTIONS &lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 11:25:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10672789#M129751</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-10-07T11:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Variable of a structure losing structure "Type"</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10673008#M129756</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp; for the input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the time, my workflow was to have a main rule run and call different rules depending on the situations. Shared Variable was my way of having a common dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are right, I probably could have improved by structuring the code differently and referencing other rules as classes and use the underlying functions instead of simply calling the rules when I needed the code in them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, as the complexity of my tool grew, I decided to take the time and move it to an AddIn.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 12:38:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10673008#M129756</guid>
      <dc:creator>j.haggenjos</dc:creator>
      <dc:date>2021-10-07T12:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Variable of a structure losing structure "Type"</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10673036#M129757</link>
      <description>&lt;P&gt;That's OK too.&amp;nbsp; But just so you know, within the iLogic system, there is also another set of tools for sharing data between rules (and even VBA macros).&amp;nbsp; You may have noticed that some of the lines of code for running another rule include 'arguments' as a NameValueMap.&amp;nbsp; You can use that to send data to the rule that that line is calling to run.&amp;nbsp; Then in the rule that is being called to run, it would need to include a bit of special code at the beginning to retrieve the data being sent to it.&amp;nbsp; The object use there is called "&lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=c6f2c020-8318-5536-3e1f-c57a5125071b" target="_blank" rel="noopener"&gt;RuleArguments&lt;/A&gt;".&amp;nbsp; You can use that to check for and retrieve any data you may be expecting when that rule starts.&amp;nbsp; &lt;A href="https://knowledge.autodesk.com/community/article/336156" target="_blank" rel="noopener"&gt;Here is a link to a contribution posts I created&lt;/A&gt; about this process of sending and receiving data between rules, if you are interested.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 12:48:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/shared-variable-of-a-structure-losing-structure-quot-type-quot/m-p/10673036#M129757</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-10-07T12:48:48Z</dc:date>
    </item>
  </channel>
</rss>

