Zero gravity command history not valid in python / vs code / omni code

Zero gravity command history not valid in python / vs code / omni code

physx.binding not valid and <omni.physx not valid… what to do?

Also, was thinking of running a recording type API to just record my clicks but i couldnt find anything, especially something that simple.

Trying to finish this for the contest.

import omni.kit.commands
from omni import physx.bindings._physx

omni.kit.commands.execute(‘SelectPrims’,
old_selected_paths=[‘/World/Sphere_01’],
new_selected_paths=[‘/World/Sphere_01’, ‘/World/Sphere_02’, ‘/World/Sphere_03’, ‘/World/Sphere_04’, ‘/World/Sphere_05’, ‘/World/Sphere_06’, ‘/World/Sphere_07’, ‘/World/Sphere_08’, ‘/World/Sphere_09’, ‘/World/Sphere_10’, ‘/World/Sphere_11’, ‘/World/Sphere_12’, ‘/World/Sphere_13’, ‘/World/Sphere_14’],
expand_in_stage=True)

omni.kit.commands.execute(‘PlacementModeTransform’,
physx_authoring=<omni.physx.bindings._physx.IPhysxAuthoring object at 0x000001DF849FCAF0>,
capture_session_id=8)

omni.kit.commands.execute(‘PlacementModeTransform’,
physx_authoring=<omni.physx.bindings._physx.IPhysxAuthoring object at 0x000001DF849FCAF0>,
capture_session_id=9)

These codes above recorded by commands in code dont work. Here is the vs code and with “”" what i need in between sections documented"“”

see code

            omni.kit.commands.execute(
                "SelectPrims",
                old_selected_paths=[],
                new_selected_paths=[
                    "/World/Sphere",
                    "/World/Sphere_01",
                    "/World/Sphere_02",
                    "/World/Sphere_03",
                    "/World/Sphere_04",
                    "/World/Sphere_05",
                    "/World/Sphere_06",
                    "/World/Sphere_07",
                    "/World/Sphere_08",
                    "/World/Sphere_09",
                    "/World/Sphere_10",
                    "/World/Sphere_11",
                    "/World/Sphere_12",
                    "/World/Sphere_13",
                    "/World/Sphere_14",
                ],
                expand_in_stage=True,
            )

“”" I want to have the previous seleted prims hold the gravity option for dynamic"“”

            omni.kit.commands.execute(
                "SelectPrims",
                old_selected_paths=[
                    "/World/Sphere",
                    "/World/Sphere_01",
                    "/World/Sphere_02",
                    "/World/Sphere_03",
                    "/World/Sphere_04",
                    "/World/Sphere_05",
                    "/World/Sphere_06",
                    "/World/Sphere_07",
                    "/World/Sphere_08",
                    "/World/Sphere_09",
                    "/World/Sphere_10",
                    "/World/Sphere_11",
                    "/World/Sphere_12",
                    "/World/Sphere_13",
                    "/World/Sphere_14",
                ],
                new_selected_paths=["/World/Plane"],
                expand_in_stage=True,
            )

“”" I want uselect the old, select new, new seleted prims hold the gravity option for static"“”
omni.kit.commands.execute(
“SelectPrims”,
old_selected_paths=[“/World/Plane”],
new_selected_paths=[
“/World/Sphere”,
“/World/Sphere_01”,
“/World/Sphere_02”,
“/World/Sphere_03”,
“/World/Sphere_04”,
“/World/Sphere_05”,
“/World/Sphere_06”,
“/World/Sphere_07”,
“/World/Sphere_08”,
“/World/Sphere_09”,
“/World/Sphere_10”,
“/World/Sphere_11”,
“/World/Sphere_12”,
“/World/Sphere_13”,
“/World/Sphere_14”,
],
expand_in_stage=True,
)

“”" I want seleted prims to play gravity option for animation"“”

Here is the vs code of what I am trying to accomplish. “”" states the goal in between selections"“”

omni.kit.commands.execute(
“SelectPrims”,
old_selected_paths=,
new_selected_paths=[
“/World/Sphere”,
“/World/Sphere_01”,
“/World/Sphere_02”,
“/World/Sphere_03”,
“/World/Sphere_04”,
“/World/Sphere_05”,
“/World/Sphere_06”,
“/World/Sphere_07”,
“/World/Sphere_08”,
“/World/Sphere_09”,
“/World/Sphere_10”,
“/World/Sphere_11”,
“/World/Sphere_12”,
“/World/Sphere_13”,
“/World/Sphere_14”,
],
expand_in_stage=True,
)
“”" I want to have the previous seleted prims hold the gravity option for dynamic"“”

            omni.kit.commands.execute(
                "SelectPrims",
                old_selected_paths=[
                    "/World/Sphere",
                    "/World/Sphere_01",
                    "/World/Sphere_02",
                    "/World/Sphere_03",
                    "/World/Sphere_04",
                    "/World/Sphere_05",
                    "/World/Sphere_06",
                    "/World/Sphere_07",
                    "/World/Sphere_08",
                    "/World/Sphere_09",
                    "/World/Sphere_10",
                    "/World/Sphere_11",
                    "/World/Sphere_12",
                    "/World/Sphere_13",
                    "/World/Sphere_14",
                ],
                new_selected_paths=["/World/Plane"],
                expand_in_stage=True,
            )

“”" I want uselect the old, select new, new seleted prims hold the gravity option for static"“”
omni.kit.commands.execute(
“SelectPrims”,
old_selected_paths=[“/World/Plane”],
new_selected_paths=[
“/World/Sphere”,
“/World/Sphere_01”,
“/World/Sphere_02”,
“/World/Sphere_03”,
“/World/Sphere_04”,
“/World/Sphere_05”,
“/World/Sphere_06”,
“/World/Sphere_07”,
“/World/Sphere_08”,
“/World/Sphere_09”,
“/World/Sphere_10”,
“/World/Sphere_11”,
“/World/Sphere_12”,
“/World/Sphere_13”,
“/World/Sphere_14”,
],
expand_in_stage=True,
)

“”" I want seleted prims to play gravity option for animation"“”

Hi @adam.wayne.hughes. Welcome! You have the right idea. I took a look at this, but I don’t think using the PlacementModeTransform Command is going to be very straight-forward. I reached out to the devs to see what the intended usage is.

Thanks, cant wait to hear back from them. I am adding textures and a few more physx options hopefully to make this fun. Im uploading a video to youtube now of what I have set so far. Its not much but its been a learning experience for me. Just using VS code is a learning experience all in itself. Here is the link tell me waht you think. Also have any ideas of what would be cool at add to this?

mind taking a look?

Learn Every Day - Omniverse Code + Python + VS Code - YouTube

Says the video is unavailable. Looks like it’s private. Try unlisted?

its just uploading still, give it like 5 min, its running the ad verification atm

Looks great! Try the CreateReference command. Drag and drop a USD, USDZ, OBJ, or glTF into the viewport or Stage window. That way you could scatter and drop more interesting meshes. :)

Hi,
yes its possible to use zero g through commands, for dropping, this is what you might want to use (copied from zero gravity python tests):

DROP_WAIT_FRAMES = 280
ENABLED_WAIT_FRAMES = 10
ACTION_WAIT_FRAMES = 5

        omni.kit.commands.execute("ZeroGravitySetEnabled", enabled=True)
        for _ in range(ENABLED_WAIT_FRAMES):
            await omni.kit.app.get_app().next_update_async()
        self._usd_context.get_selection().set_selected_prim_paths(["/World/Plane"], True)
        omni.kit.commands.execute("ZeroGravitySetSelectedStatic")
        for _ in range(ACTION_WAIT_FRAMES):
            await omni.kit.app.get_app().next_update_async()
        self._usd_context.get_selection().set_selected_prim_paths(["/World/Plane"], False)
        selected_paths = []
        for geometry in GEOMETRY:
            selected_paths.append(f"/World/{geometry}")
        self._usd_context.get_selection().set_selected_prim_paths(selected_paths, True)
        omni.kit.commands.execute("ZeroGravitySetSelectedDynamic")
        for _ in range(ACTION_WAIT_FRAMES):
            await omni.kit.app.get_app().next_update_async()
        omni.kit.commands.execute("ZeroGravitySetDropping", dropping=True)
        for _ in range(DROP_WAIT_FRAMES):
            await omni.kit.app.get_app().next_update_async()
        omni.kit.commands.execute("ZeroGravitySetDropping", dropping=False)
        for _ in range(ACTION_WAIT_FRAMES):
            await omni.kit.app.get_app().next_update_async()
        i = 0
        omni.kit.commands.execute("ZeroGravityClearAll")
        omni.kit.commands.execute("ZeroGravitySetEnabled", enabled=False)

In short:

  1. enable zero g mode
  2. select objects you want to collide, like a ground - set as static marker
  3. selected objects select as dynamic marker
  4. enable the drop
    Note that some of the operations might take a bit to get processed its no an synchronous operation, so you need run some application cycles to get things running.

Thanks Ales! Adam, let us know if you have any more follow up questions. We’ve also created an internal issue, OM-60160, to hopefully make this easier to discover in the future.

Is there a reset function something like this?

omni.kit.commands.execute(‘ZeroGravityTransformReset’)

@AlesBorovicka @mati-nvidia

or maybe something like this?

omni.kit.commands.execute(“ZeroGravitySettings”, restore=True )

Looks like there is no command, but a direct python call:

get_physx_zero_gravity_interface().mark_selection("restore", "")

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.