Transform orientations in Blender 2.80 are marked as read-only. What is the proper way to provide a custom matrix as a transform orientation in 2.80?

It looks like this call is needed to create a new orientation, which has a .matrix attribute which is NOT read only. Is this the intended usage? The user interface and docs for this don't make it clear.


2 Answers 2


It appears that the custom_orientation field of the slot is only valid if the slot type is set to the name of the custom orientation. Also, somewhere I saw a post that said that slot 0 is the slot for the 3D view's Transform Orientation. If so, searching for the correct slot shouldn't be necessary.

I really needed this feature, so this is how I did it. Assume m contains the matrix for the new orientation.

# Create view for manual alignment along baseline.
bpy.ops.transform.create_orientation(name="BASELINE", overwrite=True)
### Set baseline
slot = C.scene.transform_orientation_slots[0]
# Save current orientation setting
last_slot = slot.type
# Set new orientation (custom_orientation isn't available until we set the
# type to a custom orientation)
slot.type = 'BASELINE'
slot.custom_orientation.matrix = m
# Set orientation back to what it was
slot.type = last_slot

I haven't tested it a lot yet, but it appears to work.


Here's a working solution/snippet, with a description below:

        orthonormal_basis_matrix = mathutils.Matrix(
                [vcross[0], vnorm[0], vdest[0]],
                [vcross[1], vnorm[1], vdest[1]],
                [vcross[2], vnorm[2], vdest[2]]
        orient_slot = [
            slot for slot in
            if slot.custom_orientation
               and slot.custom_orientation.name == 'MAPlus'
        if orient_slot:
            orient_slot[0].custom_orientation.matrix = orthonormal_basis_matrix
            print('Error: Could not find MAPlus transform orientation...')
  • Call create_transformation to add a named transformation
  • Use a list comprehension to search through the available bpy.context.scene.transform_orientation_slots for a slot having a custom_orientation (TransformOrientation object) with the name you provided
  • Test whether the list comprehension/search came up with any results, then use the discovered object and set its matrix
  • $\begingroup$ transform_orientation_slots doesn't appear to work that way. custom_orientation appears to only get set in slot 0, and then only if a custom orientation is currently selected. $\endgroup$
    – Jabberwock
    Oct 12, 2020 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.