Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Small Step Iterations for Large Param Change

2 REPLIES 2
Reply
Message 1 of 3
wimann
194 Views, 2 Replies

Small Step Iterations for Large Param Change

Okay,

 

this is probably something quite easy and I'm just not thinking of the solution.

 

I want to change an angle by 5 deg steps until it reaches the full change.

 

In other words, if my desired angle is 90, then I want it to understand something like:

 

If currentangle > desiredangle then

currentangle = currentangle - 5

else if currentangle < desiredangle then

currentangle = currentangle + 5

else if currentangle = desiredangle then

end if

 

And I want for it to repeat until currentangle = desiredangle.


What am I missing?

 

Looking forward to gaining a better understanding iLogic and VB.

-Will Mann

Inventor Professional 2020
Vault Professional 2020
AutoCAD Mechanical 2020
2 REPLIES 2
Message 2 of 3
VdVeek
in reply to: wimann

Will, have a look at this site :http://inventbetter.blogspot.nl/2011/12/using-while-loop-to-backsolve.html there is a good example. One sidenote, i think it's a good idea to add a counter to the While loop with the option to quit the loop. This can prevent that the loop will never end.

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 3 of 3
Vladimir.Ananyev
in reply to: VdVeek

You may consider at least these 4 options:

 

Dim Angle As DoubleForEquals

'Debug.Print(vbNewLine & "Method 1")
For Angle = 0 To 90 Step 5
    'do something
'    Debug.Print(CStr(Angle))
Next

'Debug.Print(vbNewLine & "Method 2")
For Angle = 90 To 0 Step -5
    'do something
'    Debug.Print(CStr(Angle))
Next

'Debug.Print(vbNewLine & "Method 3")
Angle = 0 ' start value
While Angle <= 90
    'do something
'    Debug.Print(CStr(Angle))
    Angle = Angle + 5
End While

'Debug.Print(vbNewLine & "Method 4")
Angle = 90 ' start value
While Angle >= 0
    'do something
'    Debug.Print(CStr(Angle))
    Angle = Angle - 5
End While

 

Be careful when compare if X is equal to Y.

see http://forums.autodesk.com/t5/inventor-customization/ilogic-not-interpreting-parameter-value-properl...


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report