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.