Get the MRML ID of the volume being viewed through a python script

I want to get the MRML ID of the volume being viewed on the interface through a python script

For example, now I want to get the MRML ID of “20005: Screen Save” through python code, which is ‘vtkMRMLScalarVolumeNode133’
I tried using but the result is not what I want.
If anyone can help me I will be very grateful !!

The Data module lets you set all at once, but each slice view can have different data, so you can look up each one individually:"Red").mrmlSliceCompositeNode().GetBackgroundVolumeID()

(get the list of view names with

1 Like

Thank you very much !! I successfully got the ID I wanted.
but I would also like to know how you came to know this code. I am an engineering student and am developing a 3D Slicer plug-in.
thanks again for your kindness.

I had the advantage that I was one of the authors for that part of the code.

But in general, when I need to figure out how some Slicer code works I follow the method described here:

It also helps to read through the script repository, extensions, and other parts of the code just to learn what’s possible.