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, 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
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