How to get current volume and segment in Python

When going to the volumeclipmodel module, as shown in the diagram, you have to manually mouse to select the volume and segment, how to automatically get these two objects in the python code, is there a code interface? thanks!

You can get the parameter node for the VolumeClipWithModel module with this code:

volumeClipWithModelNode = slicer.mrmlScene.GetSingletonNode("VolumeClipWithModel", "vtkMRMLScriptedModuleNode")

And get the parameters with this code:

inputVolume = volumeClipWithModelNode.GetNodeReference("InputVolume")
clippingModel = volumeClipWithModelNode.GetNodeReference("ClippingModel")
outputVolume = volumeClipWithModelNode.GetNodeReference("OutputVolume")

What is your workflow?
If you are doing the segmentation in the segment editor and then exporting the segment to a model to use in volume clip with model, you can perform the masking directly within the segment editor by using the “Mask volume” effect from the “Segment Editor Extra Effects” extension.

Thank you,I wish you a happy working life! :smile:

What’s more, it’s the default not on the volumeclipwithmodel “, the display is “select a volume” and & quot;select a model”, without the mouse select, I want to get the active volume object of the volumes module from the python code, and the current model object of the module. Note that I am going to get volume and model objects in the python code, can you provide the code? Thank you so much! !!!
图片