I want to sketch the chain path of a system that consists of 2 chain rings and 1 chain tensioner ring (see print screen below). I want the sketch to be constrained by the total chain length ( = n links * x link length) so that the tensioner ring moves to the position where the chain length is a certain number. From what I've read on various forums, it is not possible to add such a constraint without writing an ilogic rule, so I wrote some code to find a solution to this.
The code works fine if I run it several times, but not when I put it into a while loop as in the code below. The problem seems to be that the dimensions in the sketch are not updated when d11 gets a new value. How do I trigger a sketch update in the code? (Manage -> Global Update)
Or is there another smarter way of doing this?
Thanks!
Dim wantedChainLength As Double
Dim n As Integer
Dim currentChainLength As Double
wantedChainLength = 1313
n = 1
currentChainLength = d5 + d8 + d9 + d10 + d12 + d13 'Sum of all the driven dimensions
While currentChainLength <> wantedChainLength And n < 10 ' "n < 10" just added temporarily while testing the code to prevent it from running forever
If currentChainLength > wantedChainLength Then
'd11 is the position of the tensioner ring
d11 = d11 - 0.1 'Will find a better solution to this later, just for testing
ElseIf currentChainLength < wantedChainLength Then
'd11 is the position of the tensioner ring
d11 = d11 + 0.1 'Will find a better solution to this later, just for testing
End If
n = n + 1
currentChainLength = d5 + d8 + d9 + d10 + d12 + d13
End While