Component rotation clockwise and counter clockwise
-
I have a dynamic component set up to rotate like this when clicked:
ANIMATESLOW("RotY",360,0)
It rotates clockwise 360 degrees perfectly, but when clicked to return to 0 degree, it still rotates clockwise instead of counter-clockwise, no matter what degree I set for the second parameter. How can I get it rotate counter-clockwise after it rotated by the first parameter.
Any help for this?Attached is my sketchUp dynamic component file.
DedongC
-
-
prokrastintor,
Thank you so much for your smart solution! and now I can use your formula to do any degrees(by changing the parameter 360),though I am not able to fully understand the code. You are great!
Just wonder if you can do me another favor? how can you make it turn forever in one direction like a real tire until click again to stop it?Thanks again! This is a good site to seek solutions.
Dedong
-
At first glance, I can't work out how to have the component spin infinitely until clicked again. My suggestion (based on your comment about a real tire) would be to investigate the SketchyPhysics plugin. There are a few small issues with it running with other plugins but overall it is a very useful tool. Note however, it will take some getting used to.
-
prokrastinator,
Thanks very much for your suggestion, I am going to learn how to use that plugin.
I just started learning the DC,Can you please explain a little bit about the formula that you used for the rotation? what the IF statement means to make the tire rotate and then reverse direction?
count_up_down =if(counter<=100, counter, 200-counter)Thanks in advance!
DedongC
-
There are two values changing here, the 'counter' and the 'count_up_down'.
The 'counter' is controlled by the animatecustom command. It goes from 0 to 100 on the first click, then up to 200 on the next click, then back down to 100 and then back down to the starting 0.
An IF statement is written like this: =if(test, true answer, false answer)
If the 'counter' is between 0 and 100 (in other words less than or equal to 100), then the 'count_up_down' value copies (equals) the 'counter' value .
example: if the 'counter' is 10 then the 'count_up_down' is 10.
The 'count_up_down' value = 200 minus the 'counter' value if the 'counter' is between 101 and 200.
example: if the 'counter' is 145 then the 'count_up_down' is 200-145 = 55.
You can then use the 'count_up_down' value to drive the rotation.
-
Thanks very much for your explanation!
I modified the formula a little bit and can get it to turn in any circles and reverse by setting up two attributes(counter and timer). Attached is my modified DC model.DedongC
-
Nice work. This is definitely a better way of tackling your original question. I'm still not sure how you can achieve your second request of continuous motion until clicked again though.
-
Thanks very much!
As I have just started learning how to do DC, I just posted another model in a new thread to seek solution.
http://sketchucation.com/forums/viewtopic.php?f=289&t=48529
Please take a look to see if you have any idea.DedongC
Advertisement