Get the parent prim selected when clicking on any part of the child prims

Hello,

Is there a way to pick up the parent prim when clicking on the child prim?

I am using the following code to subscribe to the mouse event and then search for the parent root prim:

self._input = carb.input.acquire_input_interface()
self._submouse = self._input.subscribe_to_input_events(self._on_input_event, order=0)

def _on_input_event(self, event, *_):
	if event.deviceType == carb.input.DeviceType.MOUSE:
		return self._on_global_mouse_event(event.event)
	else:
		return True

def _on_global_mouse_event(self, event, *_):
	# We care only mouse down
	while True:
		if event.type == carb.input.MouseEventType.LEFT_BUTTON_DOWN:
			selected_paths = self._usd_context.get_selection().get_selected_prim_paths()
			if len(selected_paths) > 0:
				parent = self.stage.GetPrimAtPath(selected_paths[0])
				prim_to_select = parent
				while parent:
					if parent.GetName() == "ParentPrimExample":
						prim_to_select = parent
						break
					parent = parent.GetParent()
				self.select_prim(prim_to_select)
			break
			return True

Inside “ParentPrimExample” there are many other types of prims. When I click on any of them, the code above works, but after that the child prim I’m clicking is selected again.
I just want to select the parent prim and lock my selection. Is it possible?

I tried to group all the prims inside a xform but when I click on different prims it just doesn’t select the parent.

Hi,

Yes, this is awkward and should be improved. Have you reviewed the selection mode docs?

https://docs.omniverse.nvidia.com/app_create/common/selection-modes.html?highlight=selection%20mode

Thank you, Mike. Changing the “kind” property works great.

Oh goodie. I’m still not happy with the picking experience, it needs some work, but there is some flexibility if you are willing to mark up your scene objects.

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