Using omni.services.assets.convert

I’m trying to convert a USD scene to a glTF/glb. I’ve successfully started the omni.services.assets.convert service, and can see the convert endpoint. I’ve done a default conversion with no options, but the resultant file was undisplayable as I got an error during conversion saying [Error] [omni.hydra] UsdToMdl: Resource asset path expected for parameter

I’m now trying to pass options with a ConversionRequestModel but cant get the syntax right (500 server error)

Here’s my POST body:

{
“import_path”: “omniverse://nucleusserver.co.uk/Library/Folder/USD_textured.usd”,
“output_path”: “C:/Profile/Desktop/USD_textured.gltf”,
“converter_settings”: {“ignore_materials”: “True”,
“ignore_animations”: “True”,
“ignore_camera”: “False”,
“ignore_light”: “False”,
“export_preview_surface”: “False”,
“use_meter_as_world_unit”: “False”,
“create_world_as_default_root_prim”: “True”,
“embed_textures”: “False”,
“convert_fbx_to_y_up”: “False”,
“convert_fbx_to_z_up”: “False”,
“merge_all_meshes”: “False”,
“use_double_precision_to_usd_transform_op”: “False”,
“ignore_pivots”: “False”}
}

I cant find any documentation to help and have tried reading source code, but dont seem to have the right code.

Thanks in advance,
Paul

1 Like

Hey Paul. I think your issue is that your passing Python booleans as string instead of using JSON booleans. You should be able to find the API docs here when the service is running: http://localhost:8011/docs

Here’s the example request body from the API docs:

{
  "import_path": "string",
  "output_path": "string",
  "converter_settings": {
    "baking_scales": false,
    "convert_fbx_to_y_up": false,
    "convert_fbx_to_z_up": false,
    "create_world_as_default_root_prim": true,
    "disabling_instancing": false,
    "embed_mdl_in_usd": true,
    "embed_textures": true,
    "export_hidden_props": false,
    "export_preview_surface": false,
    "ignore_animations": false,
    "ignore_camera": false,
    "ignore_light": false,
    "ignore_materials": false,
    "ignore_pivots": false,
    "keep_all_materials": false,
    "merge_all_meshes": false,
    "single_mesh": false,
    "smooth_normals": true,
    "support_point_instancer": false,
    "use_double_precision_to_usd_transform_op": false,
    "use_meter_as_world_unit": false
  }
}

Thanks for your reply. Not sure which docs you are referring to, there is no explanation of “converter_settings” in my docs.

Using your example above I get

AttributeError: ‘dict’ object has no attribute ‘ignore_materials’

Cheers,
Paul

In the “Asset Converter Folder” (omni > kit > asset_converter_impl > context.py) I found this:

It is possible to use this for convert a .USD to .FBX with animations?

Hi Paul. Which docs are you using? :) If the service is running, you should be able to access the API docs with the link I shared. You may need to try different port numbers (8011, 8111, 8211) depending on which app you’re using to run the service.

Can you share any code to understand how you’re interfacing with the service?

Hi @VanillaLake. Looks like it. These are the supported features: Asset Converter — Omniverse Extensions documentation

LOL! Thanks for your reply.

I’m looking at the docs on 8111/docs. There’s mention of converter_settings, but it has no details, just a definition containing “description”

ConversionRequestModel{

description: Model describing the request to convert a given asset to a different format.
import_path* string
title: Path of the source asset to be converted

Location where the asset to convert can be located by an Agent.|
|output_path*|string
title: Output path where to store the converted asset

Location where to place the converted asset.|
|converter_settings|Converter settings{

description: Settings to provide to the Kit Asset Converter extension in order to perform the conversion.

There is no code involved, I’m running

“app/omni.create.bat” --ext-folder D:\OmniVerse\lib\farm-queue-103.2.0\exts-farm-queue --ext-folder ./exts --enable omni.services.assets.convert

then hitting 8111 and clicking on the asset/convert and putting this in the POST body:

{
“import_path”: “omniverse://nucleus.myserver.co.uk/Library/Fulfilment/USD_textured.usd”,
“output_path”: “omniverse://nucleus.myserver.co.uk/Library/Fulfilment/USD.glb”,
“converter_settings”: {
“baking_scales”: false,
“convert_fbx_to_y_up”: false,
“convert_fbx_to_z_up”: false,
“create_world_as_default_root_prim”: true,
“disabling_instancing”: false,
“embed_mdl_in_usd”: true,
“embed_textures”: true,
“export_hidden_props”: false,
“export_preview_surface”: false,
“ignore_animations”: false,
“ignore_camera”: false,
“ignore_light”: false,
“ignore_materials”: false,
“ignore_pivots”: false,
“keep_all_materials”: false,
“merge_all_meshes”: false,
“single_mesh”: false,
“smooth_normals”: true,
“support_point_instancer”: false,
“use_double_precision_to_usd_transform_op”: false,
“use_meter_as_world_unit”: false
}
}

but I get

AttributeError: ‘dict’ object has no attribute ‘ignore_materials’

in the console window I used to start CREATE.

Even if I get this to work, I still don’t see how to specify an asset path to my materials (my OP).

Cheers,
Paul

Hi!
I used the Asset Converter from the Python Script, and got the same error “‘dict’ object has no attribute ‘ignore_materials’”
To fix it, I added the “.context” variable to each attribute (In this case, the “ignore_materials” attribute)
This is a screenshot of my code:

@VanillaLake I think that only applies to using the Python API directly. @paul.tallett is trying to use the service.

Still looking into it.

1 Like

To be honest I’ll take anything! :-) Ultimately I will probably use the Python API, I was only using the service as a test of how good the conversion is to see if it was worth investing in learning Python (never used Python).

Started my “Hello World” Python training today as I figured I’m probably going to need it.

QQ - how do I add the converter to my Hello World? I’m assuming its some sort of PIP command.

Cheers,
Paul

Apologies for the delay. I’m just catching up from the holidays. If you want to just test the conversion, you can do this interactively, but using:

  • File → Import (i.e. to USD)
  • File → Export (i.e. from USD)

That uses the same code under the hood. That will give me a bit more time to test out the service.

I can’t repro the Asset Convert Service issue. Where are you getting the omni.services.convert.asset extension from. That’s the only part I can’t understand from what you shared about how you’re executing the service.

Here is some sample code for using the Asset Converter — Omniverse Create documentation with Python. There is no need to pip install anything, but you should add omni.kit.asset_converter as a dependency in your extension’s TOML.