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

**URL:** <https://discourse.slicer.org/t/how-to-hide-the-purple-cube-in-3d-view-using-python-scripting/29734>\
**Category:** Development\
**Created:** [May 29, 2023, 10:24am UTC](https://discourse.slicer.org/t/how-to-hide-the-purple-cube-in-3d-view-using-python-scripting/29734 "2023-05-29T10:24:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)\
**Post date:** [May 29, 2023, 10:24am UTC](https://discourse.slicer.org/t/how-to-hide-the-purple-cube-in-3d-view-using-python-scripting/29734/1 "2023-05-29T10:24:48Z")

</div>

Hello Prof Lasso,

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

Thanks a lot!  
Sean

---

<div class="post-metadata">

**Author:** ![pearsonm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pearsonm/32/18514_2.png) [@pearsonm](https://discourse.slicer.org/u/pearsonm)\
**Post date:** [May 30, 2023, 1:08am UTC](https://discourse.slicer.org/t/how-to-hide-the-purple-cube-in-3d-view-using-python-scripting/29734/2 "2023-05-30T01:08:55Z")

</div>

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](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#manipulate-subject-hierarchy-item)

---

<div class="post-metadata">

**Author:** ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)\
**Post date:** [May 30, 2023, 4:27am UTC](https://discourse.slicer.org/t/how-to-hide-the-purple-cube-in-3d-view-using-python-scripting/29734/3 "2023-05-30T04:27:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [May 30, 2023, 11:24am UTC](https://discourse.slicer.org/t/how-to-hide-the-purple-cube-in-3d-view-using-python-scripting/29734/4 "2023-05-30T11:24:39Z")

</div>

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.

> [@Change color box within 3D view](https://discourse.slicer.org/t/change-color-box-within-3d-view/24350):
>
> Hi, [The issue already been asked](https://discourse.slicer.org/t/how-to-change-color-of-3d-cube-inside-3d-view/769/10) but still I’m trying to struggle with this. The idea is to modify the color of the cube from 3D view when the view is created within SlicerCAT. To solve this I need to understand how to get this cube as VTK or MRML object. Who is responsible for creating it? For example I can see that [vtkMRMLViewNode](https://github.com/Slicer/Slicer/blob/115e32bdf8e478208fc2c75179cf2ecdb555d984/Libs/MRML/Core/vtkMRMLViewNode.h#L318) has BoxVisible attribute. To modify visibility one simply triggers this attribute: viewNode = slicer.app.layoutManager().threeDWidget(0).mrmlViewNode() viewNod…

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](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#change-box-color-in-3d-view)
