Access 3d renderer for multiple view

Hi, I am wondering if it is possible to access the renderer that is associated with a view node. I am currently grabbing the view node using

slicer.util.getFirstNodeByName('View1'), but I don’t know know how to grab the renderer that is associated with that view or rather what threeDwidget the view belongs to.

I am creating a script where more than one 3d views can be created, but I need to keep track of the first one and it seems that I can’t just assume that idx = 0 in

slicer.app.layoutmanager().threeDWidget(idx).threeDView().renderWindow().GetRenderers().GetFirstRenderer()

I am using the imagedata from one of the 3d views to capture the image and create an AR overlay in the slice view.
Thank you for any help.
Peter

You should be able to iterate over the threeDWidgets and find the one that matches your view node with this call:

slicer.app.layoutManager().threeDWidget(0).threeDView().mrmlViewNode()

Thanks, I think that makes sense. I hadn’t thought of doing it that way, because I was thinking there was a direct reference between the two

You’re right, this is cleaner:

>>> v = getNode('*View*')
>>> v
(MRMLCore.vtkMRMLViewNode)0x253dc1648
>>> slicer.app.layoutManager().viewWidget(v)
qMRMLThreeDWidget(0x7fce8970bfd0, name="ThreeDWidget1") 

Thanks,
That’s so much easier to use.