Attempting to automate complex trig function with ilogic

Attempting to automate complex trig function with ilogic

Anonymous
Not applicable
437 Views
2 Replies
Message 1 of 3

Attempting to automate complex trig function with ilogic

Anonymous
Not applicable

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).

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.

 

A=235737.6 mm^2

Ro=735 mm

Atest=0 mm^2

h3=0 mm

While h3<reasonableupperlimit

     h3=h3+1 mm

     Atest=the linked equation

     If Atest>=A then

          Exit while

     end if

end while

 

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 < A, but that has given me problems as well, and I do not know why.

 

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.

0 Likes
Accepted solutions (1)
438 Views
2 Replies
Replies (2)
Message 2 of 3

MjDeck
Autodesk
Autodesk
Accepted solution

The following rule seems to work for me, in a part with millimeter units. I get h3 = 289 mm.

 

Sub Main
reasonableupperlimit = 3000 mm
A = 235737.6 mm^2
Ro=735 mm
Atest=0 mm^2
h3=0 mm
While h3<reasonableupperlimit
     h3=h3+1 mm
     Atest= TrigEquation(h3, Ro)
     If Atest>=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

 

If you want to update a sketch within the loop, you have to explicitly output the current parameter values from the rule, like this:

RuleParametersOutput()
InventorVb.DocumentUpdate()


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 3

Anonymous
Not applicable

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.

0 Likes