Help in Python Scripting to Import a Gltf Model

Hello,

there are two plugins to import gltf: the gltf importer and Datasmith gltf importer. The datasmith one leverage the gltf importer and do some extra stuff on import. I believed they will be merged in the future.

Your approach looks good, and would rely on the gltf importer route. I am not sure why it is failing, I did repro on my machine. When I tried to force the factory it also failed with a different message.

What I managed to do and I can propose to you is to go the datasmith route:

from os import path
import unreal

unreal.log("Creating Folder")
localfilePath=r"D:\Valorant_map_exporter\Test.gltf"
assetGamePath="/game/triad_art/"
assetName=path.splitext(path.basename(localfilePath))[0]
content_name="Light"
content_path=assetGamePath+content_name
#Content
unreal.EditorAssetLibrary.make_directory(content_path)
unreal.log(print(content_path))
 
datasmith_scene = unreal.DatasmithSceneElement.construct_datasmith_scene_from_file(localfilePath)
 
# set import options
import_options = datasmith_scene.get_options()
import_options.base_options.scene_handling = unreal.DatasmithImportScene.CURRENT_LEVEL
 
 
result = datasmith_scene.import_scene(assetGamePath)
 
print (result.import_succeed)
1 Like