<?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: How to write this as an external rule? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12608291#M164393</link>
    <description>&lt;P&gt;If you just want to run the rule on the file then when the file is open manually run this external rule. All I have done in this rule is to take the original parameter and use it within the parameter function. This then targets the document to the the current document open when the the rule is run. The update lines at the end update the parameters and the document. The first article linked earlier explains how the various update line works.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;If&lt;/SPAN&gt; (Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt; = 17.9375) &lt;SPAN&gt;Then&lt;/SPAN&gt;
&lt;SPAN&gt;    Parameter("FTR_POS")&lt;/SPAN&gt; = Parameter("&lt;SPAN&gt;DISTANCE_4")&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;If&lt;/SPAN&gt; (Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt; &amp;gt; 35.9375) &lt;SPAN&gt;Then&lt;/SPAN&gt;
&lt;SPAN&gt;    Parameter("FTR_POS")&lt;/SPAN&gt; = Parameter("&lt;SPAN&gt;DISTANCE_9")&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;If&lt;/SPAN&gt; ((Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt;&amp;gt; 17.9375 &lt;SPAN&gt;And&lt;/SPAN&gt; (Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt; &amp;lt; 35.9375 &lt;SPAN&gt;Or&lt;/SPAN&gt; (Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt; = 35.9375) &lt;SPAN&gt;Then&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    Parameter("FTR_POS")&lt;/SPAN&gt;= Parameter("&lt;SPAN&gt;DISTANCE_6")&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG&gt;RuleParametersOutput()&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;iLogicVb.UpdateWhenDone&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;= True.&lt;/SPAN&gt;&lt;/PRE&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;</description>
    <pubDate>Sat, 02 Mar 2024 18:01:49 GMT</pubDate>
    <dc:creator>A.Acheson</dc:creator>
    <dc:date>2024-03-02T18:01:49Z</dc:date>
    <item>
      <title>How to write this as an external rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12593242#M164378</link>
      <description>&lt;P&gt;I am brand new to iLogic and VB in general, I am trying to write an external rule that modifies one parameter based on the value of another parameter. I figured out how to write the code to do this in an internal rule but I'm unsure how to reference parameters from a specific model into an external rule. Here is what I've written for the internal rule:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN&gt;LG&lt;/SPAN&gt; = 17.9375) &lt;SPAN&gt;Then&lt;/SPAN&gt;
&lt;SPAN&gt;    FTR_POS&lt;/SPAN&gt; = &lt;SPAN&gt;DISTANCE_4&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN&gt;LG&lt;/SPAN&gt; &amp;gt; 35.9375) &lt;SPAN&gt;Then&lt;/SPAN&gt;
&lt;SPAN&gt;    FTR_POS&lt;/SPAN&gt; = &lt;SPAN&gt;DISTANCE_9&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN&gt;LG&lt;/SPAN&gt; &amp;gt; 17.9375 &lt;SPAN&gt;And&lt;/SPAN&gt; &lt;SPAN&gt;LG&lt;/SPAN&gt; &amp;lt; 35.9375 &lt;SPAN&gt;Or&lt;/SPAN&gt; &lt;SPAN&gt;LG&lt;/SPAN&gt; = 35.9375) &lt;SPAN&gt;Then&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    FTR_POS&lt;/SPAN&gt; = &lt;SPAN&gt;DISTANCE_6&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Mar 2024 14:28:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12593242#M164378</guid>
      <dc:creator>n_thomasWJZ8L</dc:creator>
      <dc:date>2024-03-01T14:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to write this as an external rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12593315#M164380</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14939919"&gt;@n_thomasWJZ8L&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This &lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-6B4885C8-7E75-4FEA-8DEF-EA7D40F33EB3" target="_blank" rel="noopener"&gt;help page here deals with parameters&lt;/A&gt; of occurrences within an assembly. You reference the occurrence name which allows the rule to find the right occurrence and effect the parameter. There is also a method that allows you to place a filepath in for the document reference which would give you a link to a document not in the assembly. As you have probably allready found out local parameters cannot be referenced in external rules.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ilogic API Parameter Function&lt;/P&gt;&lt;PRE&gt;Parameter("PartA:1", "d12") = 6.3&lt;/PRE&gt;&lt;P&gt;And for additional reading there is methods to drive and create parameters via the Inventor API. This is a step up from using the ilogic API but it has more power for extra customization.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://modthemachine.typepad.com/my_weblog/2010/04/parameters-as-iproperties.html" target="_blank" rel="noopener"&gt;Export iproperty from parameter&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://microconcepts.typepad.com/design_automation/2014/11/odoc-thisdocdocument-dim-oparams-as-parameters-if-odocdocumenttypeinventordocumenttypeenumkpartdocumentobject-t.html" target="_blank" rel="noopener"&gt;Create Parameters using vb.net&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=ParameterCreateUser_Sample" target="_blank" rel="noopener"&gt;Create Parameter VBA Sample API Help&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=Parameter" target="_blank" rel="noopener"&gt;Parameter Object API Help&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 15:07:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12593315#M164380</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2024-03-01T15:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to write this as an external rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12594279#M164392</link>
      <description>&lt;P&gt;I don't entirely comprehend the extent of what you're saying unfortunately because I'm so new there's really so much that is outside the depth of my understanding but let me try and explain my situation a bit more as I think the way it was phrased is misleading.&lt;BR /&gt;&lt;BR /&gt;I'm not trying to reference a parameter for a part that's in an assembly. My company created a form that allows us to create a set of standardized parts while only changing the features that differ between each. For this specific example I have a feature position that is based on the overall length of this part. So if the length is greater than 36 inches the distance for this feature from the end of the part needs to be 9 inches. In and of itself the simple code that I wrote in the original post works well as an internal rule for this. However my company doesn't like using internal rules because if I were to use that I would have to go to each part individually and add this code in, if something in the code breaks later I would have to make the fix in each individual variation. I want to find a way to make this an external rule so I can go through each part just run this rule and it would automatically make the change.&lt;BR /&gt;&lt;BR /&gt;I think instead of referencing the file name is there a way I could grab the parameter based off an iProperty? I think the easiest way to differentiate all these files would be to use the part number rather than trying to go off the file name.&lt;BR /&gt;&lt;BR /&gt;If you need more clarification let me know as I'm currently rushing typing this out.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 01:30:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12594279#M164392</guid>
      <dc:creator>n_thomasWJZ8L</dc:creator>
      <dc:date>2024-03-02T01:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to write this as an external rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12608291#M164393</link>
      <description>&lt;P&gt;If you just want to run the rule on the file then when the file is open manually run this external rule. All I have done in this rule is to take the original parameter and use it within the parameter function. This then targets the document to the the current document open when the the rule is run. The update lines at the end update the parameters and the document. The first article linked earlier explains how the various update line works.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;If&lt;/SPAN&gt; (Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt; = 17.9375) &lt;SPAN&gt;Then&lt;/SPAN&gt;
&lt;SPAN&gt;    Parameter("FTR_POS")&lt;/SPAN&gt; = Parameter("&lt;SPAN&gt;DISTANCE_4")&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;If&lt;/SPAN&gt; (Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt; &amp;gt; 35.9375) &lt;SPAN&gt;Then&lt;/SPAN&gt;
&lt;SPAN&gt;    Parameter("FTR_POS")&lt;/SPAN&gt; = Parameter("&lt;SPAN&gt;DISTANCE_9")&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;If&lt;/SPAN&gt; ((Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt;&amp;gt; 17.9375 &lt;SPAN&gt;And&lt;/SPAN&gt; (Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt; &amp;lt; 35.9375 &lt;SPAN&gt;Or&lt;/SPAN&gt; (Parameter("&lt;SPAN&gt;LG")&lt;/SPAN&gt; = 35.9375) &lt;SPAN&gt;Then&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    Parameter("FTR_POS")&lt;/SPAN&gt;= Parameter("&lt;SPAN&gt;DISTANCE_6")&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG&gt;RuleParametersOutput()&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;iLogicVb.UpdateWhenDone&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;= True.&lt;/SPAN&gt;&lt;/PRE&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;</description>
      <pubDate>Sat, 02 Mar 2024 18:01:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12608291#M164393</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2024-03-02T18:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to write this as an external rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12610823#M164427</link>
      <description>&lt;P&gt;Well that should work perfectly thank you so much!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 13:00:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12610823#M164427</guid>
      <dc:creator>n_thomasWJZ8L</dc:creator>
      <dc:date>2024-03-04T13:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to write this as an external rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12612336#M164440</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14939919"&gt;@n_thomasWJZ8L&lt;/a&gt;.&amp;nbsp; Just as an added bonus, if needed or desired, there is a way to maintain the automatic triggering of the rule to run every time one of those parameter values changes in that document.&amp;nbsp; You may already be aware of this, but when you include those blue, unquoted parameter names within an internal iLogic rule, that will cause that rule to get ran every time the value of one of those parameters changes.&amp;nbsp; But since we can not use those blue, unquoted parameter names within external iLogic rules that way, what I am describing below is sort of like a workaround process to maintain that auto run functionality while still having your main code in an external rule.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use an internal iLogic rule within that document that only contains some 'dummy' variables that are set to those blue, unquoted parameter names, then use a line of code to run your external iLogic rule.&amp;nbsp; Sort of like the following:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;oTrigger = LG
oTrigger = FTR_POS
oTrigger = DISTANCE_4
oTrigger = DISTANCE_6
oTrigger = DISTANCE_9
iLogicVb.Automation.RunExternalRule(ThisDoc.Document, "YourExternalRuleNameHere")&lt;/LI-CODE&gt;
&lt;P&gt;Then, every time the value of one of them changes, it will trigger this internal rule to run, which will run the external rule.&amp;nbsp; All the critical code is still in the external rule, so if it needs to change, it can be done in that one place.&amp;nbsp; This 'dummy' internal rule is just the 'middle man' for enabling the automatic 'triggering' functionality.&amp;nbsp; I use that little trick quite a bit.&amp;nbsp; The only time you might ever want/need to change anything in this internal rule is if you changed the name of the external rule.&amp;nbsp; If you rename the parameters in this document, then this internal iLogic rule should update its blue parameter names to match automatically.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 18:02:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-write-this-as-an-external-rule/m-p/12612336#M164440</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-03-04T18:02:14Z</dc:date>
    </item>
  </channel>
</rss>

