<?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: Attempting to automate complex trig function with ilogic in Inventor Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-forum/attempting-to-automate-complex-trig-function-with-ilogic/m-p/7262300#M269382</link>
    <description>&lt;P&gt;The following rule seems to work for me, in a part with millimeter units. I get h3 = 289 mm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main
reasonableupperlimit = 3000 mm
A = 235737.6 mm^2
Ro=735 mm
Atest=0 mm^2
h3=0 mm
While h3&amp;lt;reasonableupperlimit
     h3=h3+1 mm
     Atest= TrigEquation(h3, Ro)
     If Atest&amp;gt;=A Then
          Exit While
     End If
End While

Messagebox.Show(String.Format("h3 = {0} mm, Atest = {1} mm^2, A = {2} mm^2", h3, Round(Atest,2), A))

End Sub

Function TrigEquation(h3 As Double, Ro As Double) As Double
	Return (Ro*Ro/2.0) * (2.0 * Acos(1 - h3/Ro) - Sin(2 * Acos(1 - h3/Ro)))
End Function&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to update a sketch within the loop, you have to explicitly output the current parameter values from the rule, like this:&lt;BR /&gt;&lt;BR /&gt;RuleParametersOutput()&lt;BR /&gt;InventorVb.DocumentUpdate()&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jul 2017 20:16:58 GMT</pubDate>
    <dc:creator>MjDeck</dc:creator>
    <dc:date>2017-07-28T20:16:58Z</dc:date>
    <item>
      <title>Attempting to automate complex trig function with ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-forum/attempting-to-automate-complex-trig-function-with-ilogic/m-p/7262136#M269381</link>
      <description>&lt;P&gt;I am trying to automate some ducting designs, but am having some problems because of an equation that I am worried Inventor may not be able to handle on its own, of if it can, I do not know how to make it work. The attached file has the equation on it (some recognize it as a circular section area).&lt;/P&gt;&lt;P&gt;A, and Ro are known, and i need it to solve for h3 (specifically in my test file, A = 235737.589 mm^2 and Ro = 735 mm, so h3 should be about 288.96). Since h3 doesn't need an exact number, and could be rounded to the nearest mm, I had been trying to make a loop that would test h3 from 1 mm to a sensible upper limit and stop when it would cross the threshold of A and that value would be used, but the loops do not seem to be working for me. I have tried to set them up as below. I had also tried laying it out as a sketch and stopping when the sketch's area is about the same, but the document doesn't want to update the sketch mid loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A=235737.6 mm^2&lt;/P&gt;&lt;P&gt;Ro=735 mm&lt;/P&gt;&lt;P&gt;Atest=0 mm^2&lt;/P&gt;&lt;P&gt;h3=0 mm&lt;/P&gt;&lt;P&gt;While h3&amp;lt;reasonableupperlimit&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;h3=h3+1 mm&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Atest=the linked equation&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;If Atest&amp;gt;=A then&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Exit while&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end if&lt;/P&gt;&lt;P&gt;end while&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I figured that at the end of this, Atest and A should be sufficiently close, and h3 should be within 1 mm of the ideal value, but instead it is returning the upper limit every time and not exiting the while loop. I had tried structuring it the other way arround and saying while Atest &amp;lt; A, but that has given me problems as well, and I do not know why.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone see what i have done wrong here, or does anyone know the right way to go about solving this? I apologize in advance if the answer is very simple, because I have almost no actual training in inventor.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 19:07:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum/attempting-to-automate-complex-trig-function-with-ilogic/m-p/7262136#M269381</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-28T19:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Attempting to automate complex trig function with ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-forum/attempting-to-automate-complex-trig-function-with-ilogic/m-p/7262300#M269382</link>
      <description>&lt;P&gt;The following rule seems to work for me, in a part with millimeter units. I get h3 = 289 mm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main
reasonableupperlimit = 3000 mm
A = 235737.6 mm^2
Ro=735 mm
Atest=0 mm^2
h3=0 mm
While h3&amp;lt;reasonableupperlimit
     h3=h3+1 mm
     Atest= TrigEquation(h3, Ro)
     If Atest&amp;gt;=A Then
          Exit While
     End If
End While

Messagebox.Show(String.Format("h3 = {0} mm, Atest = {1} mm^2, A = {2} mm^2", h3, Round(Atest,2), A))

End Sub

Function TrigEquation(h3 As Double, Ro As Double) As Double
	Return (Ro*Ro/2.0) * (2.0 * Acos(1 - h3/Ro) - Sin(2 * Acos(1 - h3/Ro)))
End Function&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to update a sketch within the loop, you have to explicitly output the current parameter values from the rule, like this:&lt;BR /&gt;&lt;BR /&gt;RuleParametersOutput()&lt;BR /&gt;InventorVb.DocumentUpdate()&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 20:16:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum/attempting-to-automate-complex-trig-function-with-ilogic/m-p/7262300#M269382</guid>
      <dc:creator>MjDeck</dc:creator>
      <dc:date>2017-07-28T20:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Attempting to automate complex trig function with ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-forum/attempting-to-automate-complex-trig-function-with-ilogic/m-p/7265333#M269383</link>
      <description>&lt;P&gt;Thank you very much. That is running very nicely, and I was able to handle the next step in the process in a similar way.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:30:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum/attempting-to-automate-complex-trig-function-with-ilogic/m-p/7265333#M269383</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-31T12:30:56Z</dc:date>
    </item>
  </channel>
</rss>

