Reverse Count after threshold
<p>I am feeding a number slider in RhinoPython to increment the y value. I wish to reverse the increment when y equals a certain value. I have figured out how to make it negative, but that is not what I'm after. Sorry, for the simplicity of this question and thank you. In short the number slider increments the variable and once it reaches 45, then it would count down with every increment of the number slider. </p>

<pre><code>len = 45
inc = float(.1)

if y &gt;= len:
    y *= -inc
print (y)
</code></pre>

<p>First of all, don't call a variable <code>len</code>, because it is a name of standard library function.
If I understood the question correctly, the code would be</p>

<pre><code>threshold = 45
inc = .1
y = 0

while True:  # goes forever, put your own code here
    if y &gt;= threshold:
        inc *= -1
    y += inc
    print (y)
</code></pre>

<p>After y reaches 45, it start counting down. No stop condition when you count down though, it's an infinite cycle here</p>

python rhino3d