<?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: iLogic - CASE Statement Help in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7160854#M100254</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I just would like to give you an alternative to "Select case" only for your information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an "if" operator also called "ternary" with which you can get a shorter syntax for your code.&lt;/P&gt;
&lt;P&gt;(&lt;A href="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/if-operator" target="_blank"&gt;https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/if-operator&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm also used the "mod" operator to check if the given number is a multiple of 100.&lt;/P&gt;
&lt;P&gt;(&lt;A href="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/mod-operator" target="_blank"&gt;https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/mod-operator&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dist_1 = If((Val(Lenght) Mod 100) = 0, Dist_2, 0)&lt;/PRE&gt;
&lt;P&gt;This doesn't solve your last question but can be helpful to make more readable your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bregs&lt;/P&gt;
&lt;P&gt;Rossano Praderi&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jun 2017 07:51:51 GMT</pubDate>
    <dc:creator>rossano_praderi</dc:creator>
    <dc:date>2017-06-19T07:51:51Z</dc:date>
    <item>
      <title>iLogic - CASE Statement Help</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7150982#M100250</link>
      <description>&lt;P&gt;As a rookie in Inventor VBA &amp;amp; iLogic, can I ask for a quick steer on the right approach to solve what I think is a fairly simple problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to set a dimension in an iPart to be conditional on the "Length" parameter (this is the actual parameter name).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some other parameters, one of which is used as the dimension in question, it's called "Dist_1".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dist_1 will be either of two values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Condition 1: 0&lt;BR /&gt;Condition 2: The result of another calculated formula within the iPart parameters&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The iPart has 20 or so different lengths programmed into it. For every length which is a multiple of 100mm, I need to set Dist_1 to condition 2. For all others, condition 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A bit of net trawling suggest using the CASE function. I have created an iLogic rule containing the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Select Case Length&lt;BR /&gt;Case "100"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "200"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "300"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "400"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "500"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "600"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "700"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "800"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "900"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "1000"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "1100"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "1200"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "1300"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "1400"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case "1500"&lt;BR /&gt;Dist_1 =Dist_2&lt;BR /&gt;Case Else&lt;BR /&gt;Dist_1 =0&lt;BR /&gt;End Select&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clicking Save &amp;amp; Run does not generate any errors but assuming the above is correct, I'm not sure what to do next.&lt;/P&gt;
&lt;P&gt;Some questions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Is the syntax for the length values correct (are the " " needed &amp;amp; do I need to specify the units used in the parameter setting - i.e. mm)?&lt;/LI&gt;
&lt;LI&gt;How do I link the dimension in the sketch to the output of the iLogic rule?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 07:24:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7150982#M100250</guid>
      <dc:creator>arkelec</dc:creator>
      <dc:date>2017-06-14T07:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic - CASE Statement Help</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7152131#M100251</link>
      <description>&lt;P&gt;1. The quotation marks depend entirely on what data type you are comparing. Given that it LOOKS like you are using Length as a parameter, I believe that means it's type will be "DoubleForEquals". Not sure what this means for the results of your code, but you can always write a simple example program to test it out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Get the rule to set the PARAMETER, and have go into your sketch and make it reference that PARAMETER, like intended.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 14:58:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7152131#M100251</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-06-14T14:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic - CASE Statement Help</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7152405#M100252</link>
      <description>&lt;BLOCKQUOTE&gt;Thanks for replying.&lt;BR /&gt;&lt;BR /&gt;I'm not sure what point one of your answer means but agree it can be tested.&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;MechMachineMan wrote:
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Get the rule to set the PARAMETER, and have go into your sketch and make it reference that PARAMETER, like intended.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is the bit I can't seem to work out - "Get the rule to set the PARAMETER". &amp;nbsp;How &amp;amp; where is this done?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dist_1 &amp;amp; Dist_2 are already parameters (user defined) &amp;amp; the sketch dimension (d27) already references Dist_1.&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;I assume that this will all work with an iPart?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 16:16:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7152405#M100252</guid>
      <dc:creator>arkelec</dc:creator>
      <dc:date>2017-06-14T16:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic - CASE Statement Help</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7152703#M100253</link>
      <description>&lt;P&gt;OK, I think the problem might lay with updating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the "Driving Rule" column in the parameters box, it lists the name of the rule I created.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also created a form with the parameter "Length" visible so when I change that from 500 to 550mm, the DIST_1 &amp;nbsp;value changes from Dist_2 to 0 (as per the rule code).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when I "Change Component" in an assembly, the 0 value (Dist_1 parameter) is not updated.&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;Edit: &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is something else wrong. &amp;nbsp;It seems Dist_1 is either equal to Dist_2 or 0, but not both when there are two or more instances of the iPart in the same assembly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 18:17:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7152703#M100253</guid>
      <dc:creator>arkelec</dc:creator>
      <dc:date>2017-06-14T18:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic - CASE Statement Help</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7160854#M100254</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I just would like to give you an alternative to "Select case" only for your information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an "if" operator also called "ternary" with which you can get a shorter syntax for your code.&lt;/P&gt;
&lt;P&gt;(&lt;A href="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/if-operator" target="_blank"&gt;https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/if-operator&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm also used the "mod" operator to check if the given number is a multiple of 100.&lt;/P&gt;
&lt;P&gt;(&lt;A href="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/mod-operator" target="_blank"&gt;https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/mod-operator&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dist_1 = If((Val(Lenght) Mod 100) = 0, Dist_2, 0)&lt;/PRE&gt;
&lt;P&gt;This doesn't solve your last question but can be helpful to make more readable your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bregs&lt;/P&gt;
&lt;P&gt;Rossano Praderi&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 07:51:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-case-statement-help/m-p/7160854#M100254</guid>
      <dc:creator>rossano_praderi</dc:creator>
      <dc:date>2017-06-19T07:51:51Z</dc:date>
    </item>
  </channel>
</rss>

