Colorize Model of Mesh

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

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

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

:slight_smile:


image

I’ve loaded this volumetric mesh and this script 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.

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