How to set ROI of volume in python?

How can I set cropping ROi mode for a volume in python script?

If this is for volume rendering then something like this should work:

    volRenLogic = slicer.modules.volumerendering.logic()
    displayNode = volRenLogic.GetFirstVolumeRenderingDisplayNode(volumeNode)
    roiNode = displayNode.GetROINode()
    numberOfDisplayNodes = roiNode.GetNumberOfDisplayNodes()
    for i in range(numberOfDisplayNodes):
      roiNode.GetNthDisplayNode(i).SetVisibility(visible)

That helped a lot ,thank you. I don’t want to show it in the red slice view.
How can I do that?
And also how can I crop to selected ROI in python script?

If you have a question that does not fit under the title of the topic then please create a new topic. Thanks