Script Crashes Blender on "bpy.ops.transform.transform"

I made a short script and it does not work unless I take out the line with the bpy.ops.transform.transform

import bpy

bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.edge_split()
bpy.ops.mesh.separate(type='LOOSE')
bpy.ops.object.mode_set(mode = 'OBJECT')


bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')


bpy.ops.object.select_all(action='DESELECT')


area = bpy.context.area
old_type = area.type
area.type = 'VIEW_3D' 


scene = bpy.context.scene
for ob in scene.objects:
    if ob.type == 'MESH':


        scene.objects.active = ob
        


        bpy.ops.object.mode_set(mode = 'EDIT')
        bpy.ops.mesh.select_all(action='SELECT')
        bpy.ops.transform.create_orientation(name="temp", use_view=False, use=True, overwrite=True)










        bpy.ops.object.mode_set(mode = 'OBJECT')


            bpy.ops.transform.transform(constraint_orientation='temp')

I desperately need help on why this is happening! Very confused :confused:

Quick note, the purpose of this script is to separate all the faces of a mesh and align their local axes to the normals of each face. If there is a more efficient way to do this then PLEASE let me know!!!