How to change the masking setting of the segmenteditor by python?

trying to change this ‘Overwrite other segmentation’ option programmably. However, I tried the code:

defaultSegmentEditorNode = slicer.vtkMRMLSegmentEditorNode()

But it doesn’t work actually, everytime the default is still shown as ‘Allsegments’.

Any suggestions?

Thanks so much!

This changes the default. It does not affect the current setting if you have already switched to the Segment Editor before or you loaded a scene that contained a segment editor node.

You can change the masking settings in all the existing segment editor nodes like this:

for segmentEditorNode in slicer.util.getNodesByClass('vtkMRMLSegmentEditorNode'):

That really helps, Andras!

It is solved, thanks! Sorry for my late reply.