<?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: External rule - Variable hides in an enclosing block - runs internally ok in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8547076#M93598</link>
    <description>&lt;P&gt;Thankyou - that works&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jan 2019 17:47:50 GMT</pubDate>
    <dc:creator>andrew_canfield</dc:creator>
    <dc:date>2019-01-24T17:47:50Z</dc:date>
    <item>
      <title>External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8540241#M93485</link>
      <description>&lt;P&gt;hello&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've used copy &amp;amp; paste to move an iLogic rule which works locally to overwrite an external rule &amp;amp; now see this error:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Variable hides.JPG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/593845i2D857BF712B61CE1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Variable hides.JPG" alt="Variable hides.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I expose the variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 13:41:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8540241#M93485</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2019-01-22T13:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8540620#M93487</link>
      <description>&lt;P&gt;Variables declared within block statements like If/Then, Try/Catch, For/Next, etc. have "block scope" and are only available within the code block in which they're declared.&amp;nbsp;So if you try to use them outside the block, you'll get a compile error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make the variable available to your entire procedure, declare it outside the Try/Catch block, and then just set its value within the Catch block, like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim oVariable As VariableType
Try
     '...
Catch
     oVariable = ...
End Try&lt;/PRE&gt;
&lt;P&gt;I'm surprised this worked at all in your local rule. It's difficult to determine why without seeing more of your code. But regardless, you should only declare a variable within a block if it's ONLY going to be used in that block.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 15:30:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8540620#M93487</guid>
      <dc:creator>DRoam</dc:creator>
      <dc:date>2019-01-22T15:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8541135#M93488</link>
      <description>&lt;P&gt;SyntaxEditor Code Snippet&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;BE_PC&lt;/SPAN&gt; &lt;SPAN&gt;as&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;  
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;DisciplineCode&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; &lt;/PRE&gt;
&lt;P&gt;I added the lines above at the start of the code but&amp;nbsp;still see, 'BE_PC' hides &amp;amp; 'D&lt;SPAN&gt;isciplineCode' hides.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks for looking.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Andrew&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 18:10:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8541135#M93488</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2019-01-22T18:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8541151#M93489</link>
      <description>&lt;P&gt;I watch an AU tutorial which suggested bug fixing using visual studio:&lt;/P&gt;
&lt;P&gt;i'll need to watch it again!&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vb- properties.JPG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/593978i2BB4F4FF372E7ADE/image-size/large?v=v2&amp;amp;px=999" role="button" title="vb- properties.JPG" alt="vb- properties.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 18:18:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8541151#M93489</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2019-01-22T18:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8541209#M93490</link>
      <description>&lt;P&gt;So did you get it working? If not, can you post your full code? (as text, not as a picture)&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 18:40:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8541209#M93490</guid>
      <dc:creator>DRoam</dc:creator>
      <dc:date>2019-01-22T18:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8542234#M93513</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4610648"&gt;@andrew_canfield&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually, variable name (like BE_PC)&amp;nbsp;and parameter name in drawing document are same. This is actual cause for errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually, all parameters in&amp;nbsp;documents are defined with same variable name. For Example, If "&lt;STRONG&gt;BE_PC"&lt;/STRONG&gt; parameter is defined in a document, &lt;STRONG&gt;"BE_PC"&lt;/STRONG&gt; variable name is used in iLogic and can not be used again&amp;nbsp;to another variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the attached rule, I can see all variable names are same as parameter names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 05:09:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8542234#M93513</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2019-01-23T05:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8542503#M93520</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I stripped the code back &amp;amp; the error message highlights a different line to what causes the problem:&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;oDrawDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingDocument&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDrawParams&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;UserParameters&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;oDrawDoc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Parameters&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;UserParameters&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters&lt;/SPAN&gt;

&lt;SPAN&gt;Try&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Change value of param&lt;/SPAN&gt;
&lt;SPAN&gt;Parameter&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;BE_PC&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;Parameter&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;BE_PC&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;Catch&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Create Param as it doesn't exist&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;BE_PC&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;UserParameter&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;oDrawParams&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;AddByValue&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;BE_PC&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt; , &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;BE&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;UnitsTypeEnum&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;kTextUnits&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Try&lt;/SPAN&gt; &lt;/PRE&gt;
&lt;P&gt;the above works, it's adding the code below which causes the error:&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;MultiValue&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SetList&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;BE_PC&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;BE&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;PC&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;BE_PC&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;  &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;BE&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;So far:&lt;/P&gt;
&lt;P&gt;Open a drawing, check if the required parameter is there -&amp;nbsp;working&lt;/P&gt;
&lt;P&gt;if it's not there create it - working&lt;/P&gt;
&lt;P&gt;make the parameter multivalue - failing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the error is caused by lines 14 &amp;amp;&amp;nbsp; 15 - not line 11:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="14.JPG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/594122i16B90CC523F2419F/image-size/large?v=v2&amp;amp;px=999" role="button" title="14.JPG" alt="14.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 08:44:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8542503#M93520</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2019-01-23T08:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8542522#M93521</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4610648"&gt;@andrew_canfield&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be better to test the error with document. So, please provide sample document to test the situation (Make sure that files are non confidential).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 08:54:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8542522#M93521</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2019-01-23T08:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8542554#M93522</link>
      <description>&lt;P&gt;Please find sample.idw attached&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 09:03:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8542554#M93522</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2019-01-23T09:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8545302#M93567</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4610648"&gt;@andrew_canfield&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Still I strongly believe that error is due to line 12. Below iLogic code does not throw error. Just changed variable name for userparameter from &lt;STRONG&gt;BE_PC&lt;/STRONG&gt; to &lt;STRONG&gt;BE_PC_1&lt;/STRONG&gt;.&lt;/P&gt;
&lt;PRE&gt;BE_PC = "BE"' deleted parameter


Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oDrawParams As UserParameters = oDrawDoc.Parameters.UserParameters

'oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters

Try
'Change value of param
Parameter("BE_PC") = Parameter("BE_PC")
Catch
'Create Param as it doesn't exist
Dim BE_PC_1 As UserParameter = oDrawParams.AddByValue("BE_PC" , "BE", UnitsTypeEnum.kTextUnits)
End Try 

MultiValue.SetList("BE_PC", "BE", "PC")
BE_PC =  "BE"&lt;/PRE&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 05:03:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8545302#M93567</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2019-01-24T05:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: External rule - Variable hides in an enclosing block - runs internally ok</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8547076#M93598</link>
      <description>&lt;P&gt;Thankyou - that works&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 17:47:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/external-rule-variable-hides-in-an-enclosing-block-runs/m-p/8547076#M93598</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2019-01-24T17:47:50Z</dc:date>
    </item>
  </channel>
</rss>

