The operator was using a non-evaluated depsgraph to get the evaluated scene, which caused the crash. This fixes the crash reported in T66605, but not the problem where sometimes object origins aren't set.
The operator was using a non-evaluated depsgraph to get the evaluated scene, which caused the crash. This fixes the crash reported in T66605, but not the problem where sometimes object origins aren't set.