Hide 2D Segment from Showing in Certain Slice Views

Hi,

I currently have created a 2D segmentation algorithm in Python and have set my segmentations similar to how it is done in this code. Because my code is in 2D however and only segments based on the axial view, I want to hide any segment markups from the sagittal and coronal view as those segments don’t have any meaning. Is there a way to do this perhaps by modifying the voxel array or something similar? Thanks for the help in advance!

You can make nodes visible only in specific views using displayNode.SetViewNodeIDs.

See an example here using Markups:
https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#change-markup-point-list-display-properties