# Change models color

**URL:** <https://discourse.slicer.org/t/change-models-color/32971>\
**Category:** Development\
**Created:** [November 22, 2023, 9:06pm UTC](https://discourse.slicer.org/t/change-models-color/32971 "2023-11-22T21:06:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Santiago\_Cutiller](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/santiago_cutiller/32/5909_2.png) [@Santiago\_Cutiller](https://discourse.slicer.org/u/Santiago_Cutiller)\
**Post date:** [November 22, 2023, 9:06pm UTC](https://discourse.slicer.org/t/change-models-color/32971/1 "2023-11-22T21:06:34Z")

</div>

Hello! I’m trying to take my first steps in developing extensions for 3D slicer.  
I want to make an extension that changes the color of a model:

```python
model_name = "ModelName"
node_model = getNode(model_name)
node_model.GetDisplayNode().SetColor(1, 0, 0)

```

This works fine to change the color but the color is not changed in the 3D view or in the cuts.

Should the scene be updated after changing a parameter?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 23, 2023, 9:09pm UTC](https://discourse.slicer.org/t/change-models-color/32971/2 "2023-11-23T21:09:43Z")

</div>

> [@Santiago\_Cutiller](#):
>
> This works fine to change the color but the color is not changed in the 3D view or in the cuts.

Where do you see the color change?

By default, when you load a model a display node is automatically added. Have you added an additional display node for the model?

How many models do you have in the scene? Is it possible that you have loaded the same model multiple times and the one that you are changing is occluded by the others?

> [@Santiago\_Cutiller](#):
>
> Should the scene be updated after changing a parameter?

The change takes effect immediately. No manual updates are needed after changing properties of the display node.

---

<div class="post-metadata">

**Author:** ![Santiago\_Cutiller](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/santiago_cutiller/32/5909_2.png) [@Santiago\_Cutiller](https://discourse.slicer.org/u/Santiago_Cutiller)\
**Post date:** [November 24, 2023, 3:39am UTC](https://discourse.slicer.org/t/change-models-color/32971/3 "2023-11-24T03:39:36Z")

</div>

Thank you for your response.  
I see the color change in the models module but it does not change in the 3D view.

If I manually change the color from the models module, then the changes I make to the color from the Python interactor take effect. It would seem that there is something in the initial color configuration. The model is a VTK file of a tract that is initially loaded with the color I show in the image.

 ![Captura de Pantalla 2023-11-24 a la(s) 00.20.43](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/d/8dcf1558a860d26eeca6de349da267d19e77ba17.jpeg)  
 ![Captura de Pantalla 2023-11-24 a la(s) 00.21.08](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/3/43d3d95d0094e5269ab85251783dc0f3e2b33aeb.jpeg)  
 ![Captura de Pantalla 2023-11-24 a la(s) 00.26.24](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/5/4568cf01405504867ef80ebfd826c43c74204cb3.png)  
 ![Captura de Pantalla 2023-11-24 a la(s) 00.26.46](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/d/ad67668ec18b4180a860629ff3ee2954d2ea09a2.jpeg)  
 ![Captura de Pantalla 2023-11-24 a la(s) 00.28.06](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/1/b13928a6c565428662da813e34979f2ec8d9f5bd.jpeg)  
 ![Captura de Pantalla 2023-11-24 a la(s) 00.28.23](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/4/e44ad3c72728bc35b8375d4bdf4603272ddd200a.png)

---

<div class="post-metadata">

**Author:** ![Santiago\_Cutiller](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/santiago_cutiller/32/5909_2.png) [@Santiago\_Cutiller](https://discourse.slicer.org/u/Santiago_Cutiller)\
**Post date:** [November 26, 2023, 9:52pm UTC](https://discourse.slicer.org/t/change-models-color/32971/4 "2023-11-26T21:52:41Z")

</div>

Hello, I think I found the problem. The models are built from .trk files and have the Scalars visibility option active. After the instruction mi\_node.GetDisplayNode().SetScalarVisibility(False) I can change the color of the models.
