What wrong with this change handlers coding?

I'm currently working on a script that can read rotation angle of an object in real-time.

this is the code i used at this moment:

a=$cylinder01
fs= createfile "C:\\Users\\User\\Desktop\\source code5.txt"
when transform a changes do
(
in coordsys parent format "rotation-y cylinder 01 = %\n" a.rotation.y_rotation to: fs

)

and the result is as followed when i rotate the object:

rotation-y cylinder 01 = 27.9907
rotation-y cylinder 01 = 26.6364
rotation-y cylinder 01 = 27.9907
rotation-y cylinder 01 = -4.65485
rotation-y cylinder 01 = 27.9907
rotation-y cylinder 01 = -14.9164
rotation-y cylinder 01 = 27.9907
rotation-y cylinder 01 = -15.7972
rotation-y cylinder 01 = 27.9907
rotation-y cylinder 01 = -16.678
rotation-y cylinder 01 = 27.9907
rotation-y cylinder 01 = -17.5588
rotation-y cylinder 01 = 27.9907
rotation-y cylinder 01 = -19.3535
rotation-y cylinder 01 = 27.9907
rotation-y cylinder 01 = -20.6747
rotation-y cylinder 01 = 27.9907

The problem of this script is that it repeated the first angle it recorded as well. In this case, the error is the angle 27.9907, as u can see, it repeated every 2 lines.
Anyone have ideas on how to solve this bug?
i had troubleshooting for few days and i still dont know what's the problem with my code.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

Realy strange bug... it

Realy strange bug... it repeat last Z rotation angle :/

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.