trajectory of an Object animated.

i want to creat a script wich creat a splineshape from the trajectory of an animated object!!!
1-to remember what i want : select any object animated (position animation)
2-go to "Motion" then click on "Trajectories" on the "Command Panel"
3-set parameters as u want then click on "Convert To"

now u should have the splineshape of the objects trajectory.

THE question is : How can do this action with maxscript!!?

-i made a script wich creat a spline with "n" vertex (n can be as u want, bigger is "n", upper the detail u get) at the "t" time , from $my_object work,!!it mean creat a vertex each frame from $my_object.pos!!!

but i prefer the 1st solution for a simple script