Omni.kit.commands doesn't work during startup (right after app opened)

Hi, I’m trying to use omni.kit.commands during startup, but the kit plugin doens’t intialize.

2023-05-22 06:53:51 [14,594ms] [Error] [omni.kit.commands.command] Can't execute command: "DeletePrims", it wasn't registered or ambigious.
2023-05-22 06:53:51 [14,595ms] [Error] [omni.kit.commands.command] Can't execute command: "CreatePrimWithDefaultXform", it wasn't registered or ambigious.
2023-05-22 06:53:51 [14,600ms] [Error] [omni.kit.commands.command] Can't execute command: "CreatePayload", it wasn't registered or ambigious.

Also it happens when setting up cameras during loading stage in the startup function, since it also uses kit.commands

        import omni.kit.commands
        def adjust_session_camera(cam_path: Sdf.Path, adjustment: Gf.Matrix4d):
            cam_prim = stage.GetPrimAtPath(cam_path)
            xformable = UsdGeom.Xformable(cam_prim) if cam_prim else None
            if xformable:
                cur_xform = xformable.GetLocalTransformation(time_code)
                omni.kit.commands.create(
                    'TransformPrimCommand',
                    path=cam_path,
                    new_transform_matrix=cur_xform * adjustment,
                    old_transform_matrix=cur_xform,
                    time_code=time_code,
                    usd_context_name=usd_context_name
                ).do()

Is there any workaround? Thanks. (omni.usd.commands seems to work well but I don’t want to modify the official plugin)

Hi @AlanHuang. I’m following up here from our discussion on Discord. The errors to me still seem like the omni.usd extension is not being loaded before your extension that is calling the commands is loaded. I know you mentioned that you did add the dependencies, but I’d have to see more of the app to be able to debug further. A log from the app could have some useful too if you don’t want to share the source code.

1 Like

I build the clean app with executing

        omni.kit.commands.execute('CreateMeshPrimWithDefaultXform',
            prim_type='Cube',
            prim_path=None,
            select_new_prim=True,
            prepend_default_prim=True)

        omni.kit.commands.execute('CreatePrimWithDefaultXform',
            prim_type='Xform',
            prim_path=None,
            attributes={},
            select_new_prim=True)

on startup and dependency "omni.kit.commands" = {}
Here’s the full log: kit_20230529_093515.log (552.4 KB)
The error lines are at line 2183.
Thanks :)

Was this resolved?