How to hide the purple cube in 3D view using Python scripting?

Hello Prof Lasso,

Is there a way to implement hiding the magenta cube programmatically via python code?

Thanks a lot!
Sean

One way to do it is to find the node in the Subject Hierarchy and set the visibility to 0. The script repository has an example of manipulating a hierarchy item https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#manipulate-subject-hierarchy-item

Thank you - though I am not sure how to locate the magenta cube node in the subject hierarchy

With some searching in the forum you can usually find existing solutions that can help directly or indirectly with finding what you need.

For example see this post that mentions about the box in the 3D view.

Also consult the Slicer script repository for examples of common tasks that can help guide you even if it is not exactly what you desire. For example here is how to change the box color, but changing box visibility could be inferred from that example.

https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#change-box-color-in-3d-view