Inventor 2015 - iLogic - Drive Multiple Constraints

Marketing
Marketing
  • Updated

By Luke Davenport 

Today's topic: How can I animate multiple constraints at the same time in Inventor, when they are not connected by a simple relationship? 

Answer 1: Use Inventor Studio.

Answer 2: Use Showcase - send through multiple constraints to animate.

Answer 2: Use iLogic 

At the risk of being predictable - this blog will focus on an iLogic method to accomplish this. And its pretty straightforward. 

Note at this point: All credit for this model goes to Steve Brooks @ iDesk - Thanks Steve! I've just added the iLogic code to it.

Lets use the mechanical clock pictured above as our example. We have several gears meshed with each other, and a motion constraint with a certain ratio applied between each one (to give a 1/60 ratio between the minutes dial and the seconds dial for instance). No need to use iLogic for any of this, and equally, if we wanted to create any other linear motion relationships we could do this by simply applying equations between parameters, and these will be respected when we drive the constraints (see this forum article for a simple example of this: http://autode.sk/1I4M0d3)

But this clock requires a slightly more in-depth link between the movement of the components. The pendulum needs to swing from left to right, causing the 'catch' component to engage and disengage from the right hand side gear, which powers the movement. 

(See my tasteful red arrows below showing the required movement)

So how do we accomplish this? 

Well we first create two constraints with named parameters 'SecondAngle' and 'PendulumAngle'

Then we can simply do a loop in iLogic to increment these parameter values a set number of times, and when the PendulumAngle reaches the end of its swing, change it's increment from positive to negative (or vice versa)

Also - to get an animation to actually display on the screen we need to force an update of the display for each time-step.

See the code below. Of course this code won't mean much without the files themselves, so feel free to download them to play around with here. Just open the assembly file and run the iLogic rule 'Run Me'.

Hopefully this can help you if you have a similar requirement.

' Start of iLogic code
 
' Turn off user interaction for this animation
ThisApplication.UserInterfaceManager.UserInteractionDisabled = True
 
' Note the change in 'SecondAngle' equivalent to a single tooth in the gear
' is 6 degrees and the pendulum angle needs to sweep between 52 and 58 degrees...
 
' Define number of teeth we want to rotate by
Dim ToothQTY As Integer = 20
' Define no. of steps for each tooth rotation
Dim ToothStepQTY As Integer = 20
Dim DegreesPerStep As Double = 6/ToothStepQTY
 
' Set initial values for our two parameters
SecondAngle = -50
PendulumAngle = 58
 
' Update assembly to show initial positions
RuleParametersOutput()
InventorVb.DocumentUpdate()
ThisApplication.ActiveView.Update()
 
' Set boolean to control direction of pendulum
Dim Increasing As Boolean = True
 
' Loop through total quantity of steps
For i = 1 To ToothStepQTY * ToothQTY
    
    Select Case Increasing
        Case True ' PendulumAngle is increasing, and the pendulum is swinging to the left
            Select Case PendulumAngle
                Case 54.5 To 54.9 ' The pendulum is in the middle of its swing - cog needs to rotate half a tooth (3 degrees)
                    SecondAngle += 3
                    PendulumAngle = 55
                Case Is < 58 ' The pendulum is still swinging to the left
                    PendulumAngle += DegreesPerStep
                Case Else ' The pendulum needs to change direction
                    Increasing = False
            End Select
        Case False ' PendulumAngle is decreasing, and the pendulum is swinging to the right
            Select Case PendulumAngle
                Case 54.6 To 55
                    SecondAngle += 3 ' The pendulum is in the middle of its swing - cog needs to rotate half a tooth (3 degrees)
                    PendulumAngle = 54.5
                Case Is > 52 ' The pendulum is still swinging to the right
                    PendulumAngle -= DegreesPerStep
                Case Else ' The pendulum needs to change direction
                    Increasing = True
            End Select
        End Select
    
    ' Output parameters from this rule and update the assembly
    RuleParametersOutput()
    InventorVb.DocumentUpdate()
    ThisApplication.ActiveView.Update()
    
Next
 
' Turn on user interaction again
ThisApplication.UserInterfaceManager.UserInteractionDisabled = False

 

Was this article helpful?

1 out of 1 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.