I’m trying to use LevelExporterUSD from python and keep getting this error. Is this a bug or am I setting this up wrong.
LogPython: Error: Traceback (most recent call last):
LogPython: Error: File “<string>”, line 1, in <module>
LogPython: Error: File “C:\Program Files/Epic Games/UE_5.5.4/Engine/Plugins/Importers/USDImporter/Content/Python\usd_unreal\level_exporter.py”, line 1412, in export_with_cdo_options
LogPython: Error: context.root_layer_path = options_cdo.current_task.filename
LogPython: Error: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LogPython: Error: AttributeError: ‘NoneType’ object has no attribute ‘filename’
If anyone has any advice on this let me know.
Thanks,
Dave
For some reason the steps to reproduce section didn’t get added to this ticket.
This is a stripped down version of what we are using and should be enough to recreate the error. You also get the same error suppling all the options to LevelExporterUSDOptions and setting automatic to true.
lvl_path = “/Script/Engine.World’/Game/Main.Main’”
asset = unreal.load_asset(lvl_path)
task = unreal.AssetExportTask()
task.object = asset
task.filename = “C:/Exports/auto_lights.usda”
task.options = unreal.LevelExporterUSDOptions()
task.exporter = unreal.LevelExporterUSD()
unreal.Exporter.run_asset_export_task(task)
Hi Dave,
The USD level exporter is Python based, you need to call it directly. You can use the asset export task workflow to export assets to USD, but you cannot use it for level.
Something like below should work:
`from usd_unreal import level_exporter, exporting_utils
lvl_path = “/Game/MyMap.MyMap”
asset = unreal.load_asset(lvl_path)
options = unreal.LevelExporterUSDOptions()
context = exporting_utils.UsdExportContext()
context.root_layer_path = “C:/Exports/level_export.usda”
context.options = options
context.world = asset
level_exporter.export(context)`Let me know how it worked for you.
Regards,
Jean-Luc
Hi Dave,
You can only export selected actors by setting the selection_only property of the LevelExporterUSDOptions object: options.inner.selection_only = True
Obviously, you will need to programmatically select the actors you want to export.
And you can find more details on the USD Python exporter here.
Let me know how it went.
Regards,
Jean-Luc
Hey Jean-Luc sorry it’s taken me a little while to reply to this.
Thanks for answering. This works for me for exporting an entire level. Are there any docs for python USD exports? Either this or can you tell me if there is a way to export only a subset of assets from a level? What I’m looking to do is just export the lighting and nothing else.
Thanks,
Dave