Untitled

 avatar
unknown
plain_text
a month ago
840 B
2
Indexable
import bpy

def align_faces_to_orientation():

    area_type = 'VIEW_3D'
    areas = [area for area in bpy.context.window.screen.areas if area.type == area_type]
    bpy.context.scene.tool_settings.use_transform_data_origin = True

    with bpy.context.temp_override(area=areas[0]):
        if bpy.context.object.mode != 'EDIT':
            bpy.ops.object.mode_set(mode='EDIT')
            bpy.ops.transform.create_orientation(use=True)
            bpy.ops.object.editmode_toggle() # Toggles edit mode
            transform_type = bpy.context.scene.transform_orientation_slots[0].type
            bpy.ops.transform.transform(mode='ALIGN', orient_type='Face')
            bpy.ops.transform.delete_orientation(0)

            bpy.context.scene.tool_settings.use_transform_data_origin = False


align_faces_to_orientation()
Leave a Comment