Skip to content

Instantly share code, notes, and snippets.

@aobond2
Last active March 14, 2024 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aobond2/42c14cea52fe7fc04dce8897e1de81b8 to your computer and use it in GitHub Desktop.
Save aobond2/42c14cea52fe7fc04dce8897e1de81b8 to your computer and use it in GitHub Desktop.
import unreal
# Change this with desired LOD level
targetLOD = 0
# Change this with target folder for GLB output
targetFolder = "C:\\GLBExportTest\\"
targetFileFormat = ".glb"
selectedAssets = unreal.EditorUtilityLibrary.get_selected_assets()
numAssets = len(selectedAssets)
def exportGLB():
for asset in selectedAssets:
# Get folder name
directoryForAsset = unreal.Paths.get_path(asset.get_path_name())
folder = directoryForAsset.split("/")[-1]
mainBody = directoryForAsset.split("/")[-2]
individualFolder = mainBody + "\\" + folder + "\\"
task = unreal.AssetExportTask()
task.object = asset
task.filename = targetFolder + individualFolder + mainBody + "_" + folder + "_" + asset.get_name() + targetFileFormat
task.automated = True
task.replace_identical = True
task.exporter = unreal.GLTFSkeletalMeshExporter()
task.options = unreal.GLTFExportOptions()
task.options.default_level_of_detail = targetLOD
result = unreal.Exporter.run_asset_export_task(task)
print (task.filename)
exportGLB()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment