I'm running a script that appends a rig and parents it to a certain mesh but every time I run it I get an error:
EXCEPTION_ACCESS_VIOLATION. I believe it has to do with too many
bpy.ops.object.posemode_toggle()s because when I delete some of them from the code, everything works fine except for the places where I deleted them. I have been directed here: https://docs.blender.org/api/2.78b/info_gotcha.html#help-my-script-crashes-blender but it didn't seem to help. Does anyone know how to fix this?
Additionally, if I deleted the append lines, the code works fine.
Here is my code (it's very very messy): https://pastebin.com/SEd67Q9G