Here’s how it works:
To use Anchor Transform to isolate animation
In your scene, create an animated camera.
Select an object in your scene, either part of a character rig, or an object and set a key, even if the object is not animated. The object must have at least one keyframe on it, even if it is static, for the Anchor Transform trail to work.
Go to Panels > Perspective > <your animated camera name> so you view the scene through the animated camera.
Ctrl-click both the object and the current camera in the Outliner and go to Visualize >Create Editable Motion Trails > .
Activate the Anchor Transform option and click Create Motion Trail.
The Motion trail of the object from the camera's point-of-view appears when you play the animation.
Or use this Python Code:
from pymel import all as pm # Select the Control first, then the Shotcam, then run this code item,anchor = pm.selected() motion_trail = pm.snapshot(item, motionTrail=True, increment=1, startTime = pm.playbackOptions(q=1,min=1), endTime = pm.playbackOptions(q=1,max=1), anchorTransform = anchor)