Thank you for posting this. It really helped me. I was also trying to bake by the method that was in the documentation page but still I was getting errors like: “URigHeirarchy and Skeleton error”.
After reading your code I realized that we have to set the animation factory properties, i.e. specifying the skeletal mesh and the skeleton, before creating an empty animation sequence asset.