0
$\begingroup$

I'm trying to create a custom transform from selected vertices, then copy the orientation of this transform to an object.
I know it's doable from an object to another, so basically Blender copies the orientation of Active object, and rotates the Selected object to match that orientation, what I'm trying to do, using Blender API, is to copy from a custom orientation, rather than from an object.

$\endgroup$
1
$\begingroup$

The following script shows how to get to assign the custom transform orientation to the active object's orientation, after creating the custom transform orientation, and naming it (name):

import bpy
from bpy import context
import mathutils   
#Get the matrix of the transform orientation called 'name'
custom_matrix = bpy.context.scene.orientations['name'].matrix
#Copy the matrix to resize it from 3x3 matrix to 4x4 matrix
custom_matrix_4 = custom_matrix.copy()
custom_matrix_4.resize_4x4()
#Set the matrix of the active object to match the resized matrix
bpy.context.active_object.matrix_world = custom_matrix_4
$\endgroup$
  • $\begingroup$ How to do this in blender 2.8? $\endgroup$ – Alex May 30 at 5:11

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.