I'm trying to delete a Custom Transform Orientation using script, for a Custom Transform Orientation that I created using script, creating it is a breeze, no problems at all, deleting it on the other hand is a mystery, trying to execute the operation:
bpy.ops.transform.delete_orientation()
I'm getting a context is incorrect error, I tried to get the right context using the following hack, but it's not working for this specific operator, it worked for create_orientation() but not for delete_orientation():
import bpy
types = {'VIEW_3D', 'TIMELINE', 'GRAPH_EDITOR', 'DOPESHEET_EDITOR','NLA_EDITOR', 'IMAGE_EDITOR', 'SEQUENCE_EDITOR', 'CLIP_EDITOR', 'TEXT_EDITOR', 'NODE_EDITOR', 'LOGIC_EDITOR', 'PROPERTIES', 'OUTLINER', 'USER_PREFERENCES', 'INFO', 'FILE_BROWSER', 'CONSOLE'}
area = bpy.context.area.type
for type in types:
bpy.context.area.type = type
if bpy.ops.transform.delete_orientation.poll():
print(type)
bpy.context.area.type = area
Looking at the System Console after running the script above, is printing nothing, as if this operator is not available in any context in Blender! Even when I delete the Custom Transform Orientation from the Properties Shelf > Transform Orientations in 3D view, by clicking the X, nothing appears as executed in the Info Window!! Is it even possible to delete a Custom Transform Orientation using Python? I wonder why it's so easy to create one, and so hard to delete, if any one knows how to escape this incorrect context error, or how to delete a Custom Transform Orientation using a different method, would be appreciated.
Check the screen shots: