def CreateTask_SK_GlovesArmor():
		################[ Import GlovesArmor as SkeletalMesh type ]################
		print('================[ New import task : GlovesArmor as SkeletalMesh type ]================')
		FilePath = os.path.join(r'D:\Users\97ran\Documents\Unreal Projects\Lowpoly_Journey\Blender\SK_ArmorModulars\ExportedFbx\SkeletalMesh\GlovesArmor\SK_GlovesArmor.fbx')
		AdditionalParameterLoc = os.path.join(r'D:\Users\97ran\Documents\Unreal Projects\Lowpoly_Journey\Blender\SK_ArmorModulars\ExportedFbx\SkeletalMesh\GlovesArmor\SK_GlovesArmor_AdditionalParameter.ini')
		AssetImportPath = (os.path.join(unrealImportLocation, r'').replace('\\','/')).rstrip('/')
		task = unreal.AssetImportTask()
		task.filename = FilePath
		task.destination_path = AssetImportPath
		task.automated = True
		task.save = True
		task.replace_existing = True
		task.set_editor_property('options', unreal.FbxImportUI())
		task.get_editor_property('options').set_editor_property('original_import_type', unreal.FBXImportType.FBXIT_SKELETAL_MESH)
		task.get_editor_property('options').set_editor_property('import_materials', True)
		task.get_editor_property('options').set_editor_property('import_textures', False)
		task.get_editor_property('options').set_editor_property('import_animations', False)
		task.get_editor_property('options').set_editor_property('create_physics_asset', True)
		task.get_editor_property('options').set_editor_property('import_animations', False)
		task.get_editor_property('options').set_editor_property('import_mesh', True)
		task.get_editor_property('options').set_editor_property('create_physics_asset', True)
		task.get_editor_property('options').texture_import_data.set_editor_property('material_search_location', unreal.MaterialSearchLocation.LOCAL)
		task.get_editor_property('options').skeletal_mesh_import_data.set_editor_property('import_morph_targets', True)
		task.get_editor_property('options').skeletal_mesh_import_data.set_editor_property('convert_scene', True)
		print('================[ import asset : GlovesArmor ]================')
		unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
		if len(task.imported_object_paths) > 0:
			asset = unreal.find_asset(task.imported_object_paths[0])
		else:
			asset = None
		if asset == None:
			ImportFailList.append('Asset "GlovesArmor" not found for after inport')
			return
		print('========================= Imports of GlovesArmor completed ! Post treatment started...	=========================')
	
		#Import the SkeletalMesh socket(s)
		sockets_to_add = GetOptionByIniFile(AdditionalParameterLoc, 'Sockets', True)
		skeleton = asset.get_editor_property('skeleton')
		for socket in sockets_to_add:
			pass
	
		#Import the SkeletalMesh lod(s)
		lods_to_add = GetOptionByIniFile(AdditionalParameterLoc, 'LevelOfDetail')
		for x, lod in enumerate(lods_to_add):
			pass
		print('========================= Post treatment of GlovesArmor completed !	 =========================')
		unreal.EditorAssetLibrary.save_loaded_asset(asset)
		ImportedList.append([asset, 'SkeletalMesh'])
 def ImportStaticLod(lod_name, lod_number):
     if "LevelOfDetail" in additional_data:
         if lod_name in additional_data["LevelOfDetail"]:
             lodTask = unreal.AssetImportTask()
             lodTask.filename = additional_data[
                 "LevelOfDetail"][lod_name]
             destination_path = os.path.normpath(
                 asset_data["full_import_path"]).replace(
                     '\\', '/')
             lodTask.destination_path = destination_path
             lodTask.automated = True
             lodTask.replace_existing = True
             print(
                 destination_path,
                 additional_data["LevelOfDetail"][lod_name])
             unreal.AssetToolsHelpers.get_asset_tools(
             ).import_asset_tasks([lodTask])
             if len(lodTask.imported_object_paths) > 0:
                 lodAsset = unreal.find_asset(
                     lodTask.imported_object_paths[0])
                 slot_replaced = unreal.EditorStaticMeshLibrary.set_lod_from_static_mesh(
                     asset, lod_number, lodAsset, 0, True)
                 unreal.EditorAssetLibrary.delete_asset(
                     lodTask.imported_object_paths[0])
        def ImportTask():
            # New import task
            # Property
            if asset_data["type"] == "Animation":
                find_asset = unreal.find_asset(
                    asset_data["animation_skeleton_path"])
                if isinstance(find_asset, unreal.Skeleton):
                    OriginSkeleton = find_asset
                elif isinstance(find_asset, unreal.SkeletalMesh):
                    OriginSkeleton = find_asset.skeleton
                else:
                    OriginSkeleton = None

            task = unreal.AssetImportTask()
            if asset_data["type"] == "Alembic":
                task.filename = asset_data["abc_path"]
            else:
                task.filename = asset_data["fbx_path"]
            task.destination_path = os.path.normpath(
                asset_data["full_import_path"]).replace('\\', '/')
            task.automated = True
            task.save = True
            task.replace_existing = True

            if asset_data["type"] == "Alembic":
                task.set_editor_property('options', unreal.AbcImportSettings())
            else:
                task.set_editor_property('options', unreal.FbxImportUI())

            # #################################[Change]

            # unreal.FbxImportUI
            # https://docs.unrealengine.com/en-US/PythonAPI/class/FbxImportUI.html?highlight=fbximportui#unreal.FbxImportUI
            if asset_data["type"] == "Alembic":
                task.get_editor_property('options').set_editor_property(
                    'import_type', unreal.AlembicImportType.SKELETAL)

            else:
                if asset_data["type"] == "Animation":
                    if OriginSkeleton:
                        task.get_editor_property(
                            'options').set_editor_property(
                                'Skeleton', OriginSkeleton)
                    else:
                        ImportFailList.append(
                            'Skeleton ' +
                            asset_data["animation_skeleton_path"] +
                            ' Not found for ' + asset_data["name"] + ' asset.')
                        return

                if asset_data["type"] == "StaticMesh":
                    task.get_editor_property('options').set_editor_property(
                        'original_import_type',
                        unreal.FBXImportType.FBXIT_STATIC_MESH)
                elif asset_data["type"] == "Animation":
                    task.get_editor_property('options').set_editor_property(
                        'original_import_type',
                        unreal.FBXImportType.FBXIT_ANIMATION)
                else:
                    task.get_editor_property('options').set_editor_property(
                        'original_import_type',
                        unreal.FBXImportType.FBXIT_SKELETAL_MESH)

                if asset_data["type"] == "Animation":
                    task.get_editor_property('options').set_editor_property(
                        'import_materials', False)
                else:
                    task.get_editor_property('options').set_editor_property(
                        'import_materials', True)

                task.get_editor_property('options').set_editor_property(
                    'import_textures', False)

                if asset_data["type"] == "Animation":

                    task.get_editor_property('options').set_editor_property(
                        'import_animations', True)
                    task.get_editor_property('options').set_editor_property(
                        'import_mesh', False)
                    task.get_editor_property('options').set_editor_property(
                        'create_physics_asset', False)
                else:
                    task.get_editor_property('options').set_editor_property(
                        'import_animations', False)
                    task.get_editor_property('options').set_editor_property(
                        'import_mesh', True)
                    if "create_physics_asset" in asset_data:
                        task.get_editor_property(
                            'options').set_editor_property(
                                'create_physics_asset',
                                asset_data["create_physics_asset"])

                # unreal.FbxMeshImportData

                if asset_data["type"] == "StaticMesh" or asset_data[
                        "type"] == "SkeletalMesh":
                    if "material_search_location" in asset_data:
                        # unreal.FbxTextureImportData
                        if asset_data["material_search_location"] == "Local":
                            task.get_editor_property(
                                'options'
                            ).texture_import_data.set_editor_property(
                                'material_search_location',
                                unreal.MaterialSearchLocation.LOCAL)
                        if asset_data[
                                "material_search_location"] == "UnderParent":
                            task.get_editor_property(
                                'options'
                            ).texture_import_data.set_editor_property(
                                'material_search_location',
                                unreal.MaterialSearchLocation.UNDER_PARENT)
                        if asset_data[
                                "material_search_location"] == "UnderRoot":
                            task.get_editor_property(
                                'options'
                            ).texture_import_data.set_editor_property(
                                'material_search_location',
                                unreal.MaterialSearchLocation.UNDER_ROOT)
                        if asset_data[
                                "material_search_location"] == "AllAssets":
                            task.get_editor_property(
                                'options'
                            ).texture_import_data.set_editor_property(
                                'material_search_location',
                                unreal.MaterialSearchLocation.ALL_ASSETS)

                if asset_data["type"] == "StaticMesh":
                    # unreal.FbxStaticMeshImportData
                    task.get_editor_property(
                        'options').static_mesh_import_data.set_editor_property(
                            'combine_meshes', True)
                    if "auto_generate_collision" in asset_data:
                        task.get_editor_property(
                            'options'
                        ).static_mesh_import_data.set_editor_property(
                            'auto_generate_collision',
                            asset_data["auto_generate_collision"])
                    if "static_mesh_lod_group" in asset_data:
                        if asset_data["static_mesh_lod_group"]:
                            task.get_editor_property(
                                'options'
                            ).static_mesh_import_data.set_editor_property(
                                'static_mesh_lod_group',
                                asset_data["static_mesh_lod_group"])
                    if "generate_lightmap_u_vs" in asset_data:
                        task.get_editor_property(
                            'options'
                        ).static_mesh_import_data.set_editor_property(
                            'generate_lightmap_u_vs',
                            asset_data["generate_lightmap_u_vs"])

                if asset_data["type"] == "StaticMesh" or asset_data[
                        "type"] == "SkeletalMesh":

                    vertex_color_import_option = unreal.VertexColorImportOption.REPLACE  # Default
                    if "vertex_override_color" in asset_data:
                        vertex_override_color = unreal.LinearColor(
                            asset_data["vertex_override_color"][0],
                            asset_data["vertex_override_color"][1],
                            asset_data["vertex_override_color"][2])

                    if "vertex_color_import_option" in asset_data:
                        if asset_data[
                                "vertex_color_import_option"] == "IGNORE":
                            vertex_color_import_option = unreal.VertexColorImportOption.IGNORE
                        elif asset_data[
                                "vertex_color_import_option"] == "OVERRIDE":
                            vertex_color_import_option = unreal.VertexColorImportOption.OVERRIDE
                        elif asset_data[
                                "vertex_color_import_option"] == "REPLACE":
                            vertex_color_import_option = unreal.VertexColorImportOption.REPLACE

                if asset_data["type"] == "StaticMesh":
                    # unreal.FbxSkeletalMeshImportData
                    if "vertex_color_import_option" in asset_data:
                        task.get_editor_property(
                            'options'
                        ).static_mesh_import_data.set_editor_property(
                            'vertex_color_import_option',
                            vertex_color_import_option)
                    if "vertex_override_color" in asset_data:
                        task.get_editor_property(
                            'options'
                        ).static_mesh_import_data.set_editor_property(
                            'vertex_override_color',
                            vertex_override_color.to_rgbe())

                if asset_data["type"] == "SkeletalMesh":
                    # unreal.FbxSkeletalMeshImportData
                    if "vertex_color_import_option" in asset_data:
                        task.get_editor_property(
                            'options'
                        ).skeletal_mesh_import_data.set_editor_property(
                            'vertex_color_import_option',
                            vertex_color_import_option)
                    if "vertex_override_color" in asset_data:
                        task.get_editor_property(
                            'options'
                        ).skeletal_mesh_import_data.set_editor_property(
                            'vertex_override_color',
                            vertex_override_color.to_rgbe())

                if asset_data["type"] == "SkeletalMesh" or asset_data[
                        "type"] == "Animation":
                    # unreal.FbxSkeletalMeshImportData
                    task.get_editor_property(
                        'options'
                    ).skeletal_mesh_import_data.set_editor_property(
                        'import_morph_targets', True)
                    task.get_editor_property(
                        'options'
                    ).skeletal_mesh_import_data.set_editor_property(
                        'convert_scene', True)
                    task.get_editor_property(
                        'options'
                    ).skeletal_mesh_import_data.set_editor_property(
                        'normal_import_method', unreal.FBXNormalImportMethod.
                        FBXNIM_IMPORT_NORMALS_AND_TANGENTS)

            # ###############[ import asset ]################

            print("Import task")
            if asset_data["type"] == "Animation":
                '''
                For animation the script will import a skeletal mesh and remove after. 
                If the skeletal mesh alredy exist try to remove.
                '''
                # task.destination_name = "TempAnimationImportName"
                # unreal.EditorAssetLibrary.delete_asset("SkeletalMesh'"+asset_data["full_import_path"]+"/TempAnimationImportName.TempAnimationImportName'")

                unreal.EditorAssetLibrary.delete_asset(
                    "SkeletalMesh'" + asset_data["full_import_path"] + "/" +
                    asset_data["name"] + "." + asset_data["name"] + "'")

            print(
                unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(
                    [task]))
            if len(task.imported_object_paths) > 0:
                asset = unreal.find_asset(task.imported_object_paths[0])
            else:
                asset = None

            if asset is None:
                ImportFailList.append('Error zero imported object for: ' +
                                      asset_data["name"])
                return

            if asset_data["type"] == "Animation":
                # For animation remove the extra mesh
                p = task.imported_object_paths[0]
                if type(unreal.find_asset(p)) is not unreal.AnimSequence:
                    animAssetName = p.split('.')[0] + '_anim.' + p.split(
                        '.')[1] + '_anim'
                    animAssetNameDesiredPath = p.split('.')[0] + '.' + p.split(
                        '.')[1]
                    animAsset = unreal.find_asset(animAssetName)
                    if animAsset is not None:
                        unreal.EditorAssetLibrary.delete_asset(p)
                        unreal.EditorAssetLibrary.rename_asset(
                            animAssetName, animAssetNameDesiredPath)
                        asset = animAsset
                    else:
                        ImportFailList.append('animAsset ' +
                                              asset_data["name"] +
                                              ' not found for after inport: ' +
                                              animAssetName)
                        return

            # ###############[ Post treatment ]################

            if asset_data["type"] == "StaticMesh":
                if "static_mesh_lod_group" in asset_data:
                    if asset_data["static_mesh_lod_group"]:
                        asset.set_editor_property(
                            'lod_group', asset_data["static_mesh_lod_group"])
                if "light_map_resolution" in asset_data:
                    asset.set_editor_property(
                        'light_map_resolution',
                        asset_data["light_map_resolution"])

                if "collision_trace_flag" in asset_data:
                    if asset_data["collision_trace_flag"] == "CTF_UseDefault":
                        asset.get_editor_property(
                            'body_setup').set_editor_property(
                                'collision_trace_flag',
                                unreal.CollisionTraceFlag.CTF_USE_DEFAULT)
                    elif asset_data[
                            "collision_trace_flag"] == "CTF_UseSimpleAndComplex":
                        asset.get_editor_property(
                            'body_setup').set_editor_property(
                                'collision_trace_flag', unreal.
                                CollisionTraceFlag.CTF_USE_SIMPLE_AND_COMPLEX)
                    elif asset_data[
                            "collision_trace_flag"] == "CTF_UseSimpleAsComplex":
                        asset.get_editor_property(
                            'body_setup').set_editor_property(
                                'collision_trace_flag', unreal.
                                CollisionTraceFlag.CTF_USE_SIMPLE_AS_COMPLEX)
                    elif asset_data[
                            "collision_trace_flag"] == "CTF_UseComplexAsSimple":
                        asset.get_editor_property(
                            'body_setup').set_editor_property(
                                'collision_trace_flag', unreal.
                                CollisionTraceFlag.CTF_USE_COMPLEX_AS_SIMPLE)

            if asset_data["type"] == "StaticMesh" or asset_data[
                    "type"] == "SkeletalMesh":
                vertex_color_import_option = unreal.VertexColorImportOption.REPLACE  # Default
                if "vertex_override_color" in asset_data:
                    vertex_override_color = unreal.LinearColor(
                        asset_data["vertex_override_color"][0],
                        asset_data["vertex_override_color"][1],
                        asset_data["vertex_override_color"][2])

                if "vertex_color_import_option" in asset_data:
                    if asset_data["vertex_color_import_option"] == "IGNORE":
                        vertex_color_import_option = unreal.VertexColorImportOption.IGNORE
                    elif asset_data[
                            "vertex_color_import_option"] == "OVERRIDE":
                        vertex_color_import_option = unreal.VertexColorImportOption.OVERRIDE
                    elif asset_data["vertex_color_import_option"] == "REPLACE":
                        vertex_color_import_option = unreal.VertexColorImportOption.REPLACE

                if "vertex_color_import_option" in asset_data:
                    asset.get_editor_property(
                        'asset_import_data').set_editor_property(
                            'vertex_color_import_option',
                            vertex_color_import_option)
                if "vertex_override_color" in asset_data:
                    asset.get_editor_property(
                        'asset_import_data').set_editor_property(
                            'vertex_override_color',
                            vertex_override_color.to_rgbe())
            if asset_data["type"] == "StaticMesh":
                if "generate_lightmap_u_vs" in asset_data:
                    asset.get_editor_property(
                        'asset_import_data').set_editor_property(
                            'generate_lightmap_u_vs',
                            asset_data["generate_lightmap_u_vs"]
                        )  # Import data
                    unreal.EditorStaticMeshLibrary.set_generate_lightmap_uv(
                        asset, asset_data["generate_lightmap_u_vs"]
                    )  # Build settings at lod

            if asset_data["type"] == "SkeletalMesh":
                asset.get_editor_property(
                    'asset_import_data').set_editor_property(
                        'normal_import_method', unreal.FBXNormalImportMethod.
                        FBXNIM_IMPORT_NORMALS_AND_TANGENTS)

            # with open(asset_data["additional_tracks_path"], "r") as json_file:
            # asset_tracks = json.load(json_file)

            # Socket
            if asset_data["type"] == "SkeletalMesh":
                # Import the SkeletalMesh socket(s)
                sockets_to_add = GetOptionByIniFile(
                    asset_data["additional_tracks_path"], 'Sockets', True)
                skeleton = asset.get_editor_property('skeleton')
                for socket in sockets_to_add:
                    pass
                    # Create socket
                    # new_socket = unreal.SkeletalMeshSocket('', skeleton)
                    # new_socket.SocketName = socket[0]

            # Lod
            if asset_data["type"] == "StaticMesh" or asset_data[
                    "type"] == "SkeletalMesh":
                if asset_data["type"] == "StaticMesh":
                    unreal.EditorStaticMeshLibrary.remove_lods(
                        asset)  # Import the StaticMesh lod(s)

                if asset_data["type"] == "SkeletalMesh" or asset_data[
                        "type"] == "StaticMesh":
                    lods_to_add = GetOptionByIniFile(
                        asset_data["additional_tracks_path"],
                        'LevelOfDetail')  # Import the SkeletalMesh lod(s)

                    for x, lod in enumerate(lods_to_add):
                        if asset_data["type"] == "StaticMesh":
                            lodTask = unreal.AssetImportTask()
                            lodTask.filename = lod
                            lodTask.destination_path = os.path.normpath(
                                asset_data["full_import_path"]).replace(
                                    '\\', '/')
                            lodTask.automated = True
                            lodTask.replace_existing = True
                            unreal.AssetToolsHelpers.get_asset_tools(
                            ).import_asset_tasks([lodTask])
                            lodAsset = unreal.find_asset(
                                lodTask.imported_object_paths[0])
                            slot_replaced = unreal.EditorStaticMeshLibrary.set_lod_from_static_mesh(
                                asset, x + 1, lodAsset, 0, True)
                            unreal.EditorAssetLibrary.delete_asset(
                                lodTask.imported_object_paths[0])
                        elif asset_data["type"] == "SkeletalMesh":
                            pass
                            unreal.FbxMeshUtils.ImportSkeletalMeshLOD(
                                asset, lod, x + 1
                            )  # Vania unreal python dont have unreal.FbxMeshUtils.

            # #################################[EndChange]
            if asset_data["type"] == "StaticMesh" or asset_data[
                    "type"] == "SkeletalMesh":
                unreal.EditorAssetLibrary.save_loaded_asset(asset)
            ImportedList.append([asset, asset_data["type"]])
        def ImportTask():
            # New import task
            # Property

            if asset_data["type"] == "Animation":
                find_asset = unreal.find_asset(
                    asset_data["animation_skeleton_path"])
                if isinstance(find_asset, unreal.Skeleton):
                    OriginSkeleton = find_asset
                elif isinstance(find_asset, unreal.SkeletalMesh):
                    OriginSkeleton = find_asset.skeleton
                else:
                    OriginSkeleton = None

            # docs.unrealengine.com/4.26/en-US/PythonAPI/class/AssetImportTask.html
            task = unreal.AssetImportTask()

            def GetStaticMeshImportData():
                if asset_data["type"] == "StaticMesh":
                    return task.get_editor_property(
                        'options').static_mesh_import_data
                return None

            def GetSkeletalMeshImportData():
                if asset_data["type"] == "SkeletalMesh":
                    return task.get_editor_property(
                        'options').skeletal_mesh_import_data
                return None

            def GetAnimationImportData():
                if asset_data["type"] == "Animation":
                    return task.get_editor_property(
                        'options').anim_sequence_import_data
                return None

            def GetAlembicImportData():
                if asset_data["type"] == "Alembic":
                    return task.get_editor_property('options')
                return None

            def GetMeshImportData():
                if asset_data["type"] == "StaticMesh":
                    return GetStaticMeshImportData()
                if asset_data["type"] == "SkeletalMesh":
                    return GetSkeletalMeshImportData()

                return None

            if asset_data["type"] == "Alembic":
                task.filename = asset_data["abc_path"]
            else:
                task.filename = asset_data["fbx_path"]
            task.destination_path = os.path.normpath(
                asset_data["full_import_path"]).replace('\\', '/')
            task.automated = True
            # task.automated = False #Debug for show dialog
            task.save = True
            task.replace_existing = True

            if asset_data["type"] == "Alembic":
                task.set_editor_property('options', unreal.AbcImportSettings())
            else:
                task.set_editor_property('options', unreal.FbxImportUI())

            # Alembic
            if GetAlembicImportData():
                GetAlembicImportData(
                ).static_mesh_settings.set_editor_property(
                    "merge_meshes", True)
                GetAlembicImportData().set_editor_property(
                    "import_type", unreal.AlembicImportType.SKELETAL)
                GetAlembicImportData().conversion_settings.set_editor_property(
                    "flip_u", False)
                GetAlembicImportData().conversion_settings.set_editor_property(
                    "flip_v", True)
                GetAlembicImportData().conversion_settings.set_editor_property(
                    "scale", unreal.Vector(100, -100, 100))
                GetAlembicImportData().conversion_settings.set_editor_property(
                    "rotation", unreal.Vector(90, 0, 0))

            # Vertex color
            vertex_override_color = None
            vertex_color_import_option = None
            if additional_data:

                if "vertex_color_import_option" in additional_data:
                    if additional_data[
                            "vertex_color_import_option"] == "IGNORE":
                        vertex_color_import_option = unreal.VertexColorImportOption.IGNORE
                    elif additional_data[
                            "vertex_color_import_option"] == "OVERRIDE":
                        vertex_color_import_option = unreal.VertexColorImportOption.OVERRIDE
                    elif additional_data[
                            "vertex_color_import_option"] == "REPLACE":
                        vertex_color_import_option = unreal.VertexColorImportOption.REPLACE

                vertex_color_import_option = unreal.VertexColorImportOption.REPLACE  # Default
                if "vertex_override_color" in additional_data:
                    vertex_override_color = unreal.LinearColor(
                        additional_data["vertex_override_color"][0],
                        additional_data["vertex_override_color"][1],
                        additional_data["vertex_override_color"][2])

            # #################################[Change]

            # unreal.FbxImportUI
            # https://docs.unrealengine.com/4.26/en-US/PythonAPI/class/FbxImportUI.html

            # Import transform
            anim_sequence_import_data = GetAnimationImportData()
            if anim_sequence_import_data:
                anim_sequence_import_data.import_translation = unreal.Vector(
                    0, 0, 0)

            # Vertex color
            if vertex_color_import_option and GetMeshImportData():
                GetMeshImportData().set_editor_property(
                    'vertex_color_import_option', vertex_color_import_option)

            if vertex_override_color and GetMeshImportData():
                GetMeshImportData().set_editor_property(
                    'vertex_override_color', vertex_override_color.to_rgbe())

            if asset_data["type"] == "Alembic":
                task.get_editor_property('options').set_editor_property(
                    'import_type', unreal.AlembicImportType.SKELETAL)

            else:
                if asset_data["type"] == "Animation":
                    if OriginSkeleton:
                        task.get_editor_property(
                            'options').set_editor_property(
                                'Skeleton', OriginSkeleton)
                    else:
                        ImportFailList.append(
                            'Skeleton ' +
                            asset_data["animation_skeleton_path"] +
                            ' Not found for ' + asset_data["name"] + ' asset.')
                        return

                if asset_data["type"] == "StaticMesh":
                    task.get_editor_property('options').set_editor_property(
                        'original_import_type',
                        unreal.FBXImportType.FBXIT_STATIC_MESH)
                elif asset_data["type"] == "Animation":
                    task.get_editor_property('options').set_editor_property(
                        'original_import_type',
                        unreal.FBXImportType.FBXIT_ANIMATION)
                else:
                    task.get_editor_property('options').set_editor_property(
                        'original_import_type',
                        unreal.FBXImportType.FBXIT_SKELETAL_MESH)

                if asset_data["type"] == "Animation":
                    task.get_editor_property('options').set_editor_property(
                        'import_materials', False)
                else:
                    task.get_editor_property('options').set_editor_property(
                        'import_materials', True)

                task.get_editor_property('options').set_editor_property(
                    'import_textures', False)

                if asset_data["type"] == "Animation":

                    task.get_editor_property('options').set_editor_property(
                        'import_animations', True)
                    task.get_editor_property('options').set_editor_property(
                        'import_mesh', False)
                    task.get_editor_property('options').set_editor_property(
                        'create_physics_asset', False)
                else:
                    task.get_editor_property('options').set_editor_property(
                        'import_animations', False)
                    task.get_editor_property('options').set_editor_property(
                        'import_mesh', True)
                    if "create_physics_asset" in asset_data:
                        task.get_editor_property(
                            'options').set_editor_property(
                                'create_physics_asset',
                                asset_data["create_physics_asset"])

                # unreal.FbxMeshImportData

                if asset_data["type"] == "StaticMesh" or asset_data[
                        "type"] == "SkeletalMesh":
                    if "material_search_location" in asset_data:
                        # unreal.FbxTextureImportData
                        if asset_data["material_search_location"] == "Local":
                            task.get_editor_property(
                                'options'
                            ).texture_import_data.set_editor_property(
                                'material_search_location',
                                unreal.MaterialSearchLocation.LOCAL)
                        if asset_data[
                                "material_search_location"] == "UnderParent":
                            task.get_editor_property(
                                'options'
                            ).texture_import_data.set_editor_property(
                                'material_search_location',
                                unreal.MaterialSearchLocation.UNDER_PARENT)
                        if asset_data[
                                "material_search_location"] == "UnderRoot":
                            task.get_editor_property(
                                'options'
                            ).texture_import_data.set_editor_property(
                                'material_search_location',
                                unreal.MaterialSearchLocation.UNDER_ROOT)
                        if asset_data[
                                "material_search_location"] == "AllAssets":
                            task.get_editor_property(
                                'options'
                            ).texture_import_data.set_editor_property(
                                'material_search_location',
                                unreal.MaterialSearchLocation.ALL_ASSETS)

                if asset_data["type"] == "StaticMesh":
                    # unreal.FbxStaticMeshImportData
                    task.get_editor_property(
                        'options').static_mesh_import_data.set_editor_property(
                            'combine_meshes', True)
                    if "auto_generate_collision" in asset_data:
                        task.get_editor_property(
                            'options'
                        ).static_mesh_import_data.set_editor_property(
                            'auto_generate_collision',
                            asset_data["auto_generate_collision"])
                    if "static_mesh_lod_group" in asset_data:
                        if asset_data["static_mesh_lod_group"]:
                            task.get_editor_property(
                                'options'
                            ).static_mesh_import_data.set_editor_property(
                                'static_mesh_lod_group',
                                asset_data["static_mesh_lod_group"])
                    if "generate_lightmap_u_vs" in asset_data:
                        task.get_editor_property(
                            'options'
                        ).static_mesh_import_data.set_editor_property(
                            'generate_lightmap_u_vs',
                            asset_data["generate_lightmap_u_vs"])

                if asset_data["type"] == "SkeletalMesh" or asset_data[
                        "type"] == "Animation":
                    # unreal.FbxSkeletalMeshImportData
                    task.get_editor_property(
                        'options'
                    ).skeletal_mesh_import_data.set_editor_property(
                        'import_morph_targets', True)
                    task.get_editor_property(
                        'options'
                    ).skeletal_mesh_import_data.set_editor_property(
                        'convert_scene', True)
                    task.get_editor_property(
                        'options'
                    ).skeletal_mesh_import_data.set_editor_property(
                        'normal_import_method', unreal.FBXNormalImportMethod.
                        FBXNIM_IMPORT_NORMALS_AND_TANGENTS)

            # ###############[ pre import ]################

            # Check is the file alredy exit
            if additional_data:
                if "preview_import_path" in additional_data:
                    task_asset_full_path = task.destination_path + "/" + additional_data[
                        "preview_import_path"] + "." + additional_data[
                            "preview_import_path"]
                    find_asset = unreal.find_asset(task_asset_full_path)
                    if find_asset:

                        # Vertex color

                        asset_import_data = find_asset.get_editor_property(
                            'asset_import_data')
                        if vertex_color_import_option:
                            asset_import_data.set_editor_property(
                                'vertex_color_import_option',
                                vertex_color_import_option)

                        if vertex_override_color:
                            asset_import_data.set_editor_property(
                                'vertex_override_color',
                                vertex_override_color.to_rgbe())

            # ###############[ import asset ]################

            print("Import task")
            if asset_data["type"] == "Animation":
                '''
                For animation the script will import a skeletal mesh and remove after.
                If the skeletal mesh alredy exist try to remove.
                '''

                AssetName = asset_data["name"]
                AssetName = ValidUnrealAssetsName(AssetName)
                AssetPath = "SkeletalMesh'" + asset_data[
                    "full_import_path"] + "/" + AssetName + "." + AssetName + "'"

                if unreal.EditorAssetLibrary.does_asset_exist(AssetPath):
                    oldAsset = unreal.EditorAssetLibrary.find_asset_data(
                        AssetPath)
                    if oldAsset.asset_class == "SkeletalMesh":
                        unreal.EditorAssetLibrary.delete_asset(AssetPath)

            unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(
                [task])

            if len(task.imported_object_paths) > 0:
                asset = unreal.find_asset(task.imported_object_paths[0])
            else:
                asset = None

            if asset is None:
                ImportFailList.append('Error zero imported object for: ' +
                                      asset_data["name"])
                return

            if asset_data["type"] == "Animation":
                # For animation remove the extra mesh
                p = task.imported_object_paths[0]
                if type(unreal.find_asset(p)) is not unreal.AnimSequence:
                    animAssetName = p.split('.')[0] + '_anim.' + p.split(
                        '.')[1] + '_anim'
                    animAssetNameDesiredPath = p.split('.')[0] + '.' + p.split(
                        '.')[1]
                    animAsset = unreal.find_asset(animAssetName)
                    if animAsset is not None:
                        unreal.EditorAssetLibrary.delete_asset(p)
                        unreal.EditorAssetLibrary.rename_asset(
                            animAssetName, animAssetNameDesiredPath)
                        asset = animAsset
                    else:
                        ImportFailList.append('animAsset ' +
                                              asset_data["name"] +
                                              ' not found for after inport: ' +
                                              animAssetName)
                        return

            # ###############[ Post treatment ]################

            asset_import_data = asset.get_editor_property('asset_import_data')
            if asset_data["type"] == "StaticMesh":
                if "static_mesh_lod_group" in asset_data:
                    if asset_data["static_mesh_lod_group"]:
                        asset.set_editor_property(
                            'lod_group', asset_data["static_mesh_lod_group"])
                if "use_custom_light_map_resolution" in asset_data:
                    if asset_data["use_custom_light_map_resolution"]:
                        if "light_map_resolution" in asset_data:
                            asset.set_editor_property(
                                'light_map_resolution',
                                asset_data["light_map_resolution"])

                if "collision_trace_flag" in asset_data:
                    if asset_data["collision_trace_flag"] == "CTF_UseDefault":
                        asset.get_editor_property(
                            'body_setup').set_editor_property(
                                'collision_trace_flag',
                                unreal.CollisionTraceFlag.CTF_USE_DEFAULT)
                    elif asset_data[
                            "collision_trace_flag"] == "CTF_UseSimpleAndComplex":
                        asset.get_editor_property(
                            'body_setup').set_editor_property(
                                'collision_trace_flag', unreal.
                                CollisionTraceFlag.CTF_USE_SIMPLE_AND_COMPLEX)
                    elif asset_data[
                            "collision_trace_flag"] == "CTF_UseSimpleAsComplex":
                        asset.get_editor_property(
                            'body_setup').set_editor_property(
                                'collision_trace_flag', unreal.
                                CollisionTraceFlag.CTF_USE_SIMPLE_AS_COMPLEX)
                    elif asset_data[
                            "collision_trace_flag"] == "CTF_UseComplexAsSimple":
                        asset.get_editor_property(
                            'body_setup').set_editor_property(
                                'collision_trace_flag', unreal.
                                CollisionTraceFlag.CTF_USE_COMPLEX_AS_SIMPLE)

            if asset_data["type"] == "StaticMesh":
                if "generate_lightmap_u_vs" in asset_data:
                    asset_import_data.set_editor_property(
                        'generate_lightmap_u_vs',
                        asset_data["generate_lightmap_u_vs"])  # Import data
                    unreal.EditorStaticMeshLibrary.set_generate_lightmap_uv(
                        asset, asset_data["generate_lightmap_u_vs"]
                    )  # Build settings at lod

            if asset_data["type"] == "SkeletalMesh":
                asset_import_data.set_editor_property(
                    'normal_import_method', unreal.FBXNormalImportMethod.
                    FBXNIM_IMPORT_NORMALS_AND_TANGENTS)

            # Socket
            if asset_data["type"] == "SkeletalMesh":
                # Import the SkeletalMesh socket(s)
                sockets_to_add = additional_data["Sockets"]
                skeleton = asset.get_editor_property('skeleton')
                for socket in sockets_to_add:
                    old_socket = asset.find_socket(socket["SocketName"])
                    if old_socket:
                        # Edit socket
                        pass
                        # old_socket.relative_location = socket["Location"]
                        # old_socket.relative_rotation = socket["Rotation"]
                        # old_socket.relative_scale = socket["Scale"]

                    else:
                        # Create socket
                        pass
                        # new_socket = unreal.SkeletalMeshSocket(asset)
                        # new_socket.socket_name = socket["SocketName"]
                        # new_socket.bone_name = socket["BoneName"]
                        # new_socket.relative_location = socket["Location"]
                        # new_socket.relative_rotation = socket["Rotation"]
                        # new_socket.relative_scale = socket["Scale"]
                        # NEED UNREAL ENGINE IMPLEMENTATION IN PYTHON API.
                        # skeleton.add_socket(new_socket)

            # Lod
            if asset_data["type"] == "StaticMesh" or asset_data[
                    "type"] == "SkeletalMesh":
                if asset_data["type"] == "StaticMesh":
                    unreal.EditorStaticMeshLibrary.remove_lods(
                        asset)  # Import the StaticMesh lod(s)

                if asset_data["type"] == "SkeletalMesh" or asset_data[
                        "type"] == "StaticMesh":

                    def ImportStaticLod(lod_name, lod_number):
                        if "LevelOfDetail" in additional_data:
                            if lod_name in additional_data["LevelOfDetail"]:
                                lodTask = unreal.AssetImportTask()
                                lodTask.filename = additional_data[
                                    "LevelOfDetail"][lod_name]
                                destination_path = os.path.normpath(
                                    asset_data["full_import_path"]).replace(
                                        '\\', '/')
                                lodTask.destination_path = destination_path
                                lodTask.automated = True
                                lodTask.replace_existing = True
                                print(
                                    destination_path,
                                    additional_data["LevelOfDetail"][lod_name])
                                unreal.AssetToolsHelpers.get_asset_tools(
                                ).import_asset_tasks([lodTask])
                                if len(lodTask.imported_object_paths) > 0:
                                    lodAsset = unreal.find_asset(
                                        lodTask.imported_object_paths[0])
                                    slot_replaced = unreal.EditorStaticMeshLibrary.set_lod_from_static_mesh(
                                        asset, lod_number, lodAsset, 0, True)
                                    unreal.EditorAssetLibrary.delete_asset(
                                        lodTask.imported_object_paths[0])

                    def ImportSkeletalLod(lod_name, lod_number):
                        if "LevelOfDetail" in additional_data:
                            if lod_name in additional_data["LevelOfDetail"]:
                                # Unreal python no longer support Skeletal mesh LODS import.
                                pass

                    if asset_data["type"] == "StaticMesh":
                        ImportStaticLod("lod_1", 1)
                        ImportStaticLod("lod_2", 2)
                        ImportStaticLod("lod_3", 3)
                        ImportStaticLod("lod_4", 4)
                        ImportStaticLod("lod_5", 5)

                    elif asset_data["type"] == "SkeletalMesh":
                        ImportSkeletalLod("lod_1", 1)
                        ImportSkeletalLod("lod_2", 2)
                        ImportSkeletalLod("lod_3", 3)
                        ImportSkeletalLod("lod_4", 4)
                        ImportSkeletalLod("lod_5", 5)

            # Vertex color
            if vertex_override_color:
                asset_import_data.set_editor_property(
                    'vertex_override_color', vertex_override_color.to_rgbe())

            if vertex_color_import_option:
                asset_import_data.set_editor_property(
                    'vertex_color_import_option', vertex_color_import_option)

            # #################################[EndChange]
            if asset_data["type"] == "StaticMesh" or asset_data[
                    "type"] == "SkeletalMesh":
                unreal.EditorAssetLibrary.save_loaded_asset(asset)
            ImportedList.append([asset, asset_data["type"]])
示例#5
0
def test():
    matInst = unreal.find_asset('VAT_Soft_01')
示例#6
0
 def CreateTask_SK_Armature():
     ################[ Import Armature as SkeletalMesh type ]################
     print(
         '================[ New import task : Armature as SkeletalMesh type ]================'
     )
     FilePath = os.path.join(
         r'C:\Users\chenxing\Documents\ExportedFbx\SkeletalMesh\Armature\SK_Armature.fbx'
     )
     AdditionalParameterLoc = os.path.join(
         r'C:\Users\chenxing\Documents\ExportedFbx\SkeletalMesh\Armature\SK_Armature_AdditionalParameter.ini'
     )
     AssetImportPath = (os.path.join(unrealImportLocation,
                                     r'').replace('\\', '/')).rstrip('/')
     task = unreal.AssetImportTask()
     task.filename = FilePath
     task.destination_path = AssetImportPath
     task.automated = True
     task.save = True
     task.replace_existing = True
     task.set_editor_property('options', unreal.FbxImportUI())
     task.get_editor_property('options').set_editor_property(
         'original_import_type', unreal.FBXImportType.FBXIT_SKELETAL_MESH)
     task.get_editor_property('options').set_editor_property(
         'import_materials', True)
     task.get_editor_property('options').set_editor_property(
         'import_textures', False)
     task.get_editor_property('options').set_editor_property(
         'import_animations', True)
     task.get_editor_property('options').set_editor_property(
         'create_physics_asset', True)
     task.get_editor_property('options').set_editor_property(
         'import_animations', True)
     task.get_editor_property('options').set_editor_property(
         'import_mesh', True)
     task.get_editor_property('options').set_editor_property(
         'create_physics_asset', True)
     task.get_editor_property(
         'options').texture_import_data.set_editor_property(
             'material_search_location',
             unreal.MaterialSearchLocation.LOCAL)
     task.get_editor_property(
         'options').skeletal_mesh_import_data.set_editor_property(
             'import_morph_targets', True)
     print('================[ import asset : Armature ]================')
     unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
     asset = unreal.find_asset(task.imported_object_paths[0])
     if asset == None:
         ImportFailList.append(
             'Asset "Armature" not found for after inport')
         return
     print(
         '========================= Imports of Armature completed ! Post treatment started...	========================='
     )
     skeleton = asset.get_editor_property('skeleton')
     lods_to_add = GetOptionByIniFile(AdditionalParameterLoc,
                                      'LevelOfDetail')
     for x, lod in enumerate(lods_to_add):
         pass
     print(
         '========================= Post treatment of Armature completed !	 ========================='
     )
     ImportedList.append([asset, 'SkeletalMesh'])
 def CreateTask_SM_Cube038():
     ################[ Import Cube.038 as StaticMesh type ]################
     print(
         '================[ New import task : Cube.038 as StaticMesh type ]================'
     )
     FilePath = os.path.join(
         r'C:\Users\heads\OneDrive\Рабочий стол\Git PUSH\Level-arc\Bilder\ExportedFbx\StaticMesh\SM_Cube038.fbx'
     )
     AdditionalParameterLoc = os.path.join(
         r'C:\Users\heads\OneDrive\Рабочий стол\Git PUSH\Level-arc\Bilder\ExportedFbx\StaticMesh\SM_Cube.038_AdditionalParameter.ini'
     )
     AssetImportPath = (os.path.join(unrealImportLocation,
                                     r'').replace('\\', '/')).rstrip('/')
     task = unreal.AssetImportTask()
     task.filename = FilePath
     task.destination_path = AssetImportPath
     task.automated = True
     task.save = True
     task.replace_existing = True
     task.set_editor_property('options', unreal.FbxImportUI())
     task.get_editor_property('options').set_editor_property(
         'original_import_type', unreal.FBXImportType.FBXIT_STATIC_MESH)
     task.get_editor_property('options').set_editor_property(
         'import_materials', True)
     task.get_editor_property('options').set_editor_property(
         'import_textures', False)
     task.get_editor_property('options').set_editor_property(
         'import_animations', False)
     task.get_editor_property('options').set_editor_property(
         'import_mesh', True)
     task.get_editor_property('options').set_editor_property(
         'create_physics_asset', True)
     task.get_editor_property(
         'options').texture_import_data.set_editor_property(
             'material_search_location',
             unreal.MaterialSearchLocation.LOCAL)
     task.get_editor_property(
         'options').static_mesh_import_data.set_editor_property(
             'combine_meshes', True)
     task.get_editor_property(
         'options').static_mesh_import_data.set_editor_property(
             'auto_generate_collision', True)
     task.get_editor_property(
         'options').static_mesh_import_data.set_editor_property(
             'static_mesh_lod_group', 'None')
     task.get_editor_property(
         'options').static_mesh_import_data.set_editor_property(
             'generate_lightmap_u_vs', True)
     print('================[ import asset : Cube.038 ]================')
     unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
     asset = unreal.find_asset(task.imported_object_paths[0])
     if asset == None:
         ImportFailList.append(
             'Asset "Cube.038" not found for after inport')
         return
     print(
         '========================= Imports of Cube.038 completed ! Post treatment started...	========================='
     )
     asset.set_editor_property('lod_group', 'None')
     asset.get_editor_property('body_setup').set_editor_property(
         'collision_trace_flag', unreal.CollisionTraceFlag.CTF_USE_DEFAULT)
     lods_to_add = GetOptionByIniFile(AdditionalParameterLoc,
                                      'LevelOfDetail')
     for x, lod in enumerate(lods_to_add):
         pass
     print(
         '========================= Post treatment of Cube.038 completed !	 ========================='
     )
     ImportedList.append([asset, 'StaticMesh'])
    def CreateTask_SM_LegModule001():
        ################[ Import LegModule.001 as StaticMesh type ]################
        print(
            '================[ New import task : LegModule.001 as StaticMesh type ]================'
        )
        FilePath = os.path.join(
            r'D:\Users\97ran\Documents\Unreal Projects\Lowpoly_Journey\Blender\ExportedFbx\StaticMesh\SM_LegModule001.fbx'
        )
        AdditionalParameterLoc = os.path.join(
            r'D:\Users\97ran\Documents\Unreal Projects\Lowpoly_Journey\Blender\ExportedFbx\StaticMesh\SM_LegModule.001_AdditionalParameter.ini'
        )
        AssetImportPath = (os.path.join(unrealImportLocation,
                                        r'').replace('\\', '/')).rstrip('/')
        task = unreal.AssetImportTask()
        task.filename = FilePath
        task.destination_path = AssetImportPath
        task.automated = True
        task.save = True
        task.replace_existing = True
        task.set_editor_property('options', unreal.FbxImportUI())
        task.get_editor_property('options').set_editor_property(
            'original_import_type', unreal.FBXImportType.FBXIT_STATIC_MESH)
        task.get_editor_property('options').set_editor_property(
            'import_materials', True)
        task.get_editor_property('options').set_editor_property(
            'import_textures', False)
        task.get_editor_property('options').set_editor_property(
            'import_animations', False)
        task.get_editor_property('options').set_editor_property(
            'import_mesh', True)
        task.get_editor_property('options').set_editor_property(
            'create_physics_asset', True)
        task.get_editor_property(
            'options').texture_import_data.set_editor_property(
                'material_search_location',
                unreal.MaterialSearchLocation.LOCAL)
        task.get_editor_property(
            'options').static_mesh_import_data.set_editor_property(
                'combine_meshes', True)
        task.get_editor_property(
            'options').static_mesh_import_data.set_editor_property(
                'auto_generate_collision', True)
        task.get_editor_property(
            'options').static_mesh_import_data.set_editor_property(
                'static_mesh_lod_group', 'None')
        task.get_editor_property(
            'options').static_mesh_import_data.set_editor_property(
                'generate_lightmap_u_vs', True)
        print(
            '================[ import asset : LegModule.001 ]================')
        unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
        if len(task.imported_object_paths) > 0:
            asset = unreal.find_asset(task.imported_object_paths[0])
        else:
            asset = None
        if asset == None:
            ImportFailList.append(
                'Asset "LegModule.001" not found for after inport')
            return
        print(
            '========================= Imports of LegModule.001 completed ! Post treatment started...	========================='
        )
        asset.set_editor_property('lod_group', 'None')
        asset.get_editor_property('body_setup').set_editor_property(
            'collision_trace_flag', unreal.CollisionTraceFlag.CTF_USE_DEFAULT)
        asset.get_editor_property('asset_import_data').set_editor_property(
            'vertex_color_import_option',
            unreal.VertexColorImportOption.IGNORE)

        #Import the StaticMesh lod(s)
        unreal.EditorStaticMeshLibrary.remove_lods(asset)
        lods_to_add = GetOptionByIniFile(AdditionalParameterLoc,
                                         'LevelOfDetail')
        for x, lod in enumerate(lods_to_add):
            lodTask = unreal.AssetImportTask()
            lodTask.filename = lod
            lodTask.destination_path = AssetImportPath
            lodTask.automated = True
            lodTask.replace_existing = True
            unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(
                [lodTask])
            lodAsset = unreal.find_asset(lodTask.imported_object_paths[0])
            slot_replaced = unreal.EditorStaticMeshLibrary.set_lod_from_static_mesh(
                asset, x + 1, lodAsset, 0, True)
            unreal.EditorAssetLibrary.delete_asset(
                lodTask.imported_object_paths[0])
        print(
            '========================= Post treatment of LegModule.001 completed !	 ========================='
        )
        unreal.EditorAssetLibrary.save_loaded_asset(asset)
        ImportedList.append([asset, 'StaticMesh'])