I'm trying to update a script I used in 2.79 to delete all custom transform orientations (CTOs).
The new API replaced
bpy.context.scene.transform_orientations_slots. The problem is, for some reason, this is returning only the active CTO, not a list of the CTOs that I created. I couldn't find a way to return a list of CTOs so I can later iterate through them and delete them.
Researching the matter, the closest thing I could find is
However this is not useful in my case, since the argument will only accept a string enum.
Also the info window isn't helping. When I change the Transform Orientation manually, the listener is printing
bpy.context.scene.type = "TO_Name". Trying to use this in the console or the script will throw an
AttributeError: 'Scene' object has no attribute 'type'.
Following is the script. If you try it, it will only delete the CTO if it's already active. My question is, how to get the list of the CTOs?
import bpy orient = bpy.context.scene.transform_orientation_slots views = [area.spaces.active for area in bpy.context.screen.areas if area.type == 'VIEW_3D'] areas = [area for area in bpy.context.window.screen.areas if area.type == 'VIEW_3D'] for o in orient: if views and areas: views = o override = bpy.context.copy() override['area']= areas try: bpy.ops.transform.delete_orientation(override) except: pass