Clear stage selection from extension

After manually selecting prims in stage browser this should remove the selections

import omni.usd
omni.usd.get_context().get_selection().clear_selected_prim_paths()

and it does work but throws that error

[Error] [omni.kit.manipulator.prim.model] Traceback (most recent call last):
[Error] [omni.kit.manipulator.prim.model]   File "d:\users\...\ov\pkg\create-2022.3.3\kit\extscore\omni.kit.manipulator.prim\omni\kit\manipulator\prim\model.py", line 1505, in _update_transform_from_prims_async
[Error] [omni.kit.manipulator.prim.model]     pivot_prim_path = self._pivot_prim.GetPath()
[Error] [omni.kit.manipulator.prim.model] AttributeError: 'NoneType' object has no attribute 'GetPath'

how could the error be prevented ?

Hi @volker.kuehn. I wasn’t able to repro this on my end. I think what would help next is:

  1. Share you log files: How to Report an issue with Omniverse
  2. Share a simple scene and exact repro steps in case it has something to do with the content you selected.

Hi @mati-nvidia ,

and now it happens again. so it does not always happen !

  • Operating System Windows 10 // Ubuntu 20.04
  • GPU / GPU Driver Quadro P600 / 526.67 // RTX 2060
  • Application(s) Used / Version Number Create 2022.3.3
  • Full log file (if applicable)

Steps
Create a a Cube (Mash or Shape doens’t matter)
Select one of the created
Open the Script editor
Paste the two lines of code from above and hit “Run”

Regards

Still no luck for me in reproducing it. If you can attach the log files, we can at least look through the logs to hopefully understand why/when it happens.

sorry I should have attached it already

kit_20230317_083514.log (863.6 KB)

company names replaced. Would be nice to have a safe way to share these things

Oh, that’s helpful. There are other errors in there about using an invalid stage. I think the problem may be somewhere else in your code. That you’re using omni.usd.get_context().get_stage() to get the UsdStage object that you’re using. This is typically the Stage that is open in the app and the one you want to interact with.

It actually looks like during the start phase of omniverse there is no stage for the extension and therefor got that error wenn accessing it in the init phase.

I have put the get_stage infront of any access. Works but just does not look nice in the code.
@mati-nvidia thanks keep looking at it

Hi @volker.kuehn. Yes, it’s expected that the default stage may not be loaded when your extension starts. Another case that you want to watch out for is that user can close and open a new stage since your extension started, so it’s on the developer to get the current stage and make sure that it’s valid throughout. You can use StageEvents for that: Omni.USD — omni.kit.usd_docs 1.1.1 documentation

Hi @mati-nvidia ,

that’s a really valuable hint !
The code does look a bit different from what you usually see in the documentation and I have to admit I don’t understand everything right now, I’ll keep it in the belt for once I have more knowledge.

Cheers

1 Like

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