slicer.mrmlScene.Clear() not working

I’m running Slicer 5.8.1 on Windows 11. Inputting slicer.mrmlScene.Clear() in the python console is not clearing it as before. Is this an issue or is it just me? Is there another way of clearing it?

I can’t reproduce this. Clearing the scene works fine for me. What’s not clearing for you?

Thanks for the report.

To help us understand, could you report the following:

  • The version of Slicer used to reproduce the issue
  • The extensions installed if any

Also, does the issue happen using a newly installed Slicer just after loading MRHead sample data ? Or after running installing extensions and/or running scripts ?

She uses 5.8.1.

Further concrete questions:

  • Is there any error in the log after a failed clear scene execution?
  • Does Slicer crash?
  • Or what you said means that some nodes are not removed?

Maybe I didn’t state it correctly. The Scene clears but the console does not. Is this normal behavior for slicer.mrmlScene.Clear()?

I don’t have extensions installed. I’m using it after running a script.

That’s normal - we typically don’t clear the python console when the scene closes.

But you can do this if you want:

slicer.util.pythonShell().clear()
2 Likes