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 with 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 bpy.ops.transform.select_orientation(orientation="some_CTO_name").

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'.

The Script:

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[0] = o
        override = bpy.context.copy()
        override['area']= areas[0]
  • 1
    $\begingroup$ I decided to put together a Blender Addon based on Iyad Ahmed's script to help out my workflow in Blender and it is working fine. You are all welcome to give it a try. Hope it can be useful for you guys too. It is good for Blender 2.80 and newer versions. The Custom Transform Orientations Purge addon can be found at my public GitHub repository at this link $\endgroup$
    – mmmrqs
    Commented Nov 10, 2021 at 20:55

3 Answers 3


I was trying to solve the same problem, came up with this workaround.

If we tried to set transform_orientation_slots[0].type to a non existent value, we get this error:

TypeError: bpy_struct: item.attr = val: enum "" not found in ('GLOBAL', 'LOCAL', 'NORMAL', 'GIMBAL', 'VIEW', 'CURSOR', 'Cub', 'Cube', 'Cube.001', 'Cube.002', 'Cube.003', 'Cube.004', 'Cube.005', 'Cube.006', 'Cube.007', 'Cube.008', 'Cube.009', 'Cube.010', 'Cube.011', 'Cube.012')

The idea is to try and set that property, catch the error message, do string manipulation, and have a list of transform orientations.

After that we loop through custom orientations, set the transform orientation to it, and execute bpy.ops.transform.delete_orientation(), the script seems to be working well,

import bpy

    bpy.context.scene.transform_orientation_slots[0].type = ""
except Exception as inst:
    transforms = str(inst).split("'")[1::2]

transform_list = list(transforms)
for enum_type in transform_list[7:]: # The 7 first orientations are builtins
    bpy.context.scene.transform_orientation_slots[0].type = enum_type

I really hope there's a better solution if anyone has, I tried bl_rna["type"].enum_items, but it just returns the default orientations, not the custom ones, perhaps I'm missing something.

  • 1
    $\begingroup$ This works perfectly, many thanks! $\endgroup$
    – Georges D
    Commented Oct 7, 2020 at 18:28
  • 1
    $\begingroup$ yes triggering the exception and extracting the list is currently the only way to also get the custom values. It's only possible to directly get the list of the built-in transforms using: for t in bpy.types.TransformOrientationSlot.bl_rna.properties['type'].enum_items: print("Built-in:", t.name) $\endgroup$
    – Harry McKenzie
    Commented Aug 2, 2023 at 10:04

As for Blender 3.6 the script by @iyad-ahmed stopped working because Blender added new builtin orientation PARENT.

Previous script was relying that there will be exactly 6 builtins, I've updated the script so that it will get the actual list of builtin transformations so it won't break the next time Blender adds/removes new transformation.

PS there is still no other way to get list of all custom orientations besides parsing exception message and excluding builting.

import bpy

context = bpy.context
transform_slots = context.scene.transform_orientation_slots
builtin_transforms = [i.identifier for i in bpy.types.TransformOrientationSlot.bl_rna.properties['type'].enum_items]

# hacky (but the only way) to get the all available transforms
    context.scene.transform_orientation_slots[0].type = ""
except Exception as inst:
    transforms = str(inst).split("'")[1::2]

for transform in transforms:
    if transform in builtin_transforms:
    transform_slots[0].type = transform
  • $\begingroup$ Still working as of Blender 4.1. Thank you. $\endgroup$
    – dt192
    Commented Apr 1 at 1:06
orient_slot = bpy.context.scene.transform_orientation_slots[0]
custom = orient_slot.custom_orientation

reference: https://blenderartists.org/t/2-80-cheat-sheet-for-updating-add-ons/1148974

  • $\begingroup$ bpy.context.scene.transform_orientation_slots[0] returns the active transform orientation, I'm looking for a way to get a list of the custom transform orientations, I don't see how your answer relates to my question. $\endgroup$
    – Georges D
    Commented Jul 17, 2019 at 14:30
  • $\begingroup$ maybe iterate over slots ? $\endgroup$
    – user34831
    Commented Aug 2, 2019 at 19:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .