# Colorize Model of Mesh

**URL:** <https://discourse.slicer.org/t/colorize-model-of-mesh/9778>\
**Category:** Support\
**Tags:** segmentation, 3d-model\
**Created:** [January 11, 2020, 8:49am UTC](https://discourse.slicer.org/t/colorize-model-of-mesh/9778 "2020-01-11T08:49:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [January 11, 2020, 8:49am UTC](https://discourse.slicer.org/t/colorize-model-of-mesh/9778/1 "2020-01-11T08:49:06Z")

</div>

I want to Colorize Mesh of the Volumetic Meshes. so i did simple python script from script repository of slicer document. but it does not work.

```
modelNode = slicer.util.getNode('Model') # select cells in this model

cellScalars = modelNode.GetMesh().GetCellData() # select cell data in this model

selectionArray = cellScalars.GetArray('labels') # select current active scalar in this model

for i in range(0, 10000):

    selectionArray.SetValue(i, 100) # set selected cell's scalar value to non-zero

selectionArray.Modified()

```

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/3/d3d3edb0cc9d7e9db74372d62723e941e7e44021.png)

---

<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:** [January 11, 2020, 6:05pm UTC](https://discourse.slicer.org/t/colorize-model-of-mesh/9778/2 "2020-01-11T18:05:43Z")

</div>

You also need to select the scalar array to be used for coloring (in Models module, Scalars section).

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [January 13, 2020, 6:20am UTC](https://discourse.slicer.org/t/colorize-model-of-mesh/9778/3 "2020-01-13T06:20:43Z")

</div>

You also need to select the scalar array to be used for coloring (in Models module, Scalars section).  
==\> Yes. I did but have no effect on the Display of Meshes

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/e/befa1d575bac3e046126584e86b515865d0d7ab8.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/2/2228ca9eb9d0df57c0deca6a72db8d75eca36c7a.png)

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [January 14, 2020, 5:55am UTC](https://discourse.slicer.org/t/colorize-model-of-mesh/9778/4 "2020-01-14T05:55:37Z")

</div>

🙂

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/0/f022770e992f2a307e5a4c329d5eed80be02f6ec.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/2/423c6c23fefe84fee8979e35dbf35fedbcf3ee22.png)

---

<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:** [January 15, 2020, 3:16am UTC](https://discourse.slicer.org/t/colorize-model-of-mesh/9778/5 "2020-01-15T03:16:21Z")

</div>

I’ve loaded this [volumetric mesh](https://raw.githubusercontent.com/Slicer/Slicer/master/Libs/MRML/Core/Testing/TestData/PentaHexa.vtk) and [this script](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Select_cells_of_a_model_using_markups_fiducial_points) and it worked well for me. Try if it works for you, too. If it does then change things step by step to see what is different in your data or code.

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [January 15, 2020, 3:51am UTC](https://discourse.slicer.org/t/colorize-model-of-mesh/9778/6 "2020-01-15T03:51:36Z")

</div>

Good approach, step by step.

previously, i did your code and got the result but i did not capture the result. so i am suspicious about my memory.

i will do it and change the code for my purpose ^^.  
and share the code in this page

---

<div class="post-metadata">

**Author:** ![lausiv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lausiv/32/4984_2.png) [@lausiv](https://discourse.slicer.org/u/lausiv)\
**Post date:** [January 20, 2020, 10:15pm UTC](https://discourse.slicer.org/t/colorize-model-of-mesh/9778/7 "2020-01-20T22:15:08Z")

</div>

It works on the meshed model 😀 😀 😀

Korea time, early morning from 5 AM to 8 for 3 hour. very consenstrate upon slicer open source based image processing & graphics time for enjoyment now^^

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/9/3966ca593d864a3dd6cfb11700ce417af2cfbcb2.png)
