# Model visualization

**URL:** <https://discourse.slicer.org/t/model-visualization/21469>\
**Category:** Support\
**Tags:** python, visualization, 3d-model\
**Created:** [January 14, 2022, 9:01pm UTC](https://discourse.slicer.org/t/model-visualization/21469 "2022-01-14T21:01:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luca](https://avatars.discourse-cdn.com/v4/letter/l/51bf81/32.png) [@Luca](https://discourse.slicer.org/u/Luca)\
**Post date:** [January 14, 2022, 9:01pm UTC](https://discourse.slicer.org/t/model-visualization/21469/1 "2022-01-14T21:01:01Z")

</div>

Dear community,

I imported a model by python scripting with the following lines:

inputModel = slicer.util.loadModel(model\_path)  
inputModel.SetDisplayVisibility(1)  
inputModel.GetDisplayNode().SetOpacity(0.25)  
inputModel.GetDisplayNode().SetColor(1,1,1)

then I did some operations in it and now I want to see if my pipeline worked well. I have a vtkpolydata object as output and, starting from here [Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#show-a-simple-surface-mesh-as-a-model-node), I import my result back in Slicer with the following function:

def slicer\_model\_node(model, node\_name, visibility=0, opacity=1, color=(255,0,0)):  
model\_Node = slicer.modules.models.logic().AddModel(model)  
model\_Node.SetName(node\_name)  
model\_Node.SetDisplayVisibility(visibility)  
model\_Node.GetDisplayNode().SetOpacity(opacity)  
model\_Node.GetDisplayNode().SetColor(color)  
model\_Node.GetDisplayNode().SetLighting(1)#  
model\_Node.GetDisplayNode().SetAmbient(0.0)#  
model\_Node.GetDisplayNode().SetDiffuse(1)#  
model\_Node.GetDisplayNode().SetPower(1)#  
model\_Node.GetDisplayNode().SetLighting(1)#  
model\_Node.GetDisplayNode().SetInterpolation(1)#  
model\_Node.GetDisplayNode().SetShading(1)#  
return model\_Node

However the result is the following: left=new model, right=input model

 ![immagine](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/e/7ee0a0feed692a753bce5999a3b770ad5cf45671.png)

Could you please tell me which lines I miss or which I wrongly wrote? (Lines with “#” at the end were added later to verify if they were the missing ones). I think it is a problem of shading or lighting but I didn’t manage to find the right way.

Thank you in advance

---

<div class="post-metadata">

**Author:** ![Luca](https://avatars.discourse-cdn.com/v4/letter/l/51bf81/32.png) [@Luca](https://discourse.slicer.org/u/Luca)\
**Post date:** [January 16, 2022, 9:28pm UTC](https://discourse.slicer.org/t/model-visualization/21469/2 "2022-01-16T21:28:59Z")

</div>

Solved: color components must be between 0 and 1, not 0-255
