Open Python.blend
for an example Blender file that contains all scripts.
Supported versions: Blender 3+ and 4+
Align bone to a Custom Transform Orientation and recalculate roll so that the bone Z axis points along the custom orientation X axis.
Run the
op_align_bone_to_transform_orientation.py
script once to register the new "Align Bone to Transform Orientation" operation.
op_align_bone_to_transform_orientation.py
-
Go into Edit Mode (
Tab
when in Object Mode). -
Switch to Face Select mode (
3
). -
Select an object face.
-
Create a Custom Transform Orientation.
Two options:
-
Option 1: Open the command palette (
F3
or Edit --> Menu Search), type "transform create orientation" and execute the "Create Orientation" command. This will create a new Custom Transform Orientation called "Face" (by default). (Note: Older Blender versions will not automatically select the transform it. See: step 5.) -
Option 2: Open the "Transform Orientations" menu in the header of your 3D Viewport editor and click on the
+
button. This will create a new Custom Transform Orientation called "Face" (by default) and automatically select it.
-
-
If your new Custom Transform Orientation isn't already selected: Open the "Transform Orientations" menu in the header of your 3D Viewport editor and select "Face" at the bottom. ("Face" is the default name if this was the first manually created custom orientation.)
-
Snap (
Shift+S
) --> Cursor to Selected -
Select an existing armature and enter Edit Mode.
-
Either add a new bone or select an existing bone.
-
Open the command palette (
F3
) and type "Align Bone to Transform Orientation".
Or: Right click the bone in Edit Mode and select the same operation. -
Now the bone sits orthogonal on the selected face and is rolled in a way that its Z axis points along the X axis of the Custom Transform Orientation.
-
The newly created "Face" orientation can now be deleted.
Just a couple of test scripts.
Get location of a vertex and move cursor to Z +1 in local space.
Show object info and convert vertex coordinates between local and global space.