After loading model file, the Red, Green and Yellow slices remain beyond the model.
I guess thatâs why the Red slice plane cut isnât doing any work.
I solved the problem.
Thanks Sunderland and Lasso
The solution is as below:
pointCoordinates = slicer.util.arrayFromModelPoints(InputBeyinModelNode)
import numpy as np
position = np.average(pointCoordinates, axis=0)
# Center slice views and cameras on this position
for sliceNode in slicer.util.getNodesByClass('vtkMRMLSliceNode'):
sliceNode.JumpSliceByCentering(*position)
for camera in slicer.util.getNodesByClass('vtkMRMLCameraNode'):
camera.SetFocalPoint(position)
# red slicedan kes
redSliceNode = slicer.util.getFirstNodeByClassByName("vtkMRMLSliceNode", "Red")
dynamicModelerNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLDynamicModelerNode")
dynamicModelerNode.SetToolName("Plane cut")
dynamicModelerNode.SetNodeReferenceID("PlaneCut.InputModel", InputBeyinModelNode.GetID())
dynamicModelerNode.SetNodeReferenceID("PlaneCut.InputPlane", redSliceNode.GetID())
dynamicModelerNode.SetNodeReferenceID("PlaneCut.OutputPositiveModel", OutputBeyinModelNode.GetID())
slicer.modules.dynamicmodeler.logic().RunDynamicModelerTool(dynamicModelerNode)