# vtkCutter

**URL:** https://discourse.vtk.org/t/vtkcutter/2337
**Category:** Development
**Created:** [December 26, 2019, 4:48am UTC](https://discourse.vtk.org/t/vtkcutter/2337 "2019-12-26T04:48:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![snehal](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@snehal](https://discourse.vtk.org/u/snehal)
#### Post date: [December 26, 2019, 4:48am UTC](https://discourse.vtk.org/t/vtkcutter/2337/1 "2019-12-26T04:48:28Z")

</div>

Hello all,  
I am new in VTK please help me to resolve the following issue.  
I have volume data when i try to pass in vtkCutter function its give me the following error

volume = vtk.vtkVolume()  
volume.SetMapper(volumeMapper)  
volume.SetProperty(volumeProperty)

#create a plane to cut,here it cuts in the XZ direction (xz normal=(1,0,0);XY =(0,0,1),YZ =(0,1,0)  
plane=vtk.vtkPlane()  
plane.SetOrigin(10,0,0)  
plane.SetNormal(1,0,0)

#create cutter  
cutter=vtk.vtkCutter()  
cutter.SetCutFunction(plane)  
cutter.SetInputConnection(volume.GetOutputPort())  
cutter.Update()  
cutterMapper=vtk.vtkPolyDataMapper()  
cutterMapper.SetInputConnection( cutter.GetOutputPort())

#create plane actor  
planeActor=vtk.vtkActor()  
planeActor.GetProperty().SetColor(1.0,1,0)  
planeActor.GetProperty().SetLineWidth(2)  
planeActor.SetMapper(cutterMapper)

AttributeError :Traceback (most recent call last)  
 in   
7 cutter=vtk.vtkCutter()  
8 cutter.SetCutFunction(plane)  
----\> 9 cutter.SetInputConnection(volume.GetOutputPort())  
10 cutter.Update()  
11 cutterMapper=vtk.vtkPolyDataMapper()

AttributeError: ‘vtkRenderingCorePython.vtkVolume’ object has no attribute ‘GetOutputPort’

---

<div class="post-metadata">

### Author: ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)
#### Post date: [December 27, 2019, 12:37am UTC](https://discourse.vtk.org/t/vtkcutter/2337/2 "2019-12-27T00:37:53Z")

</div>

…if you already have a volume object this should work:

```python
    #vol = vtkVolume()
    boxWidget = vtk.vtkBoxWidget()
    boxWidget.SetInteractor(vp.interactor)
    boxWidget.SetPlaceFactor(1.0)

    renderer.AddVolume(vol)
    interactor.Render()

    planes = vtk.vtkPlanes()
    def clipVolumeRender(obj, event):
        obj.GetPlanes(planes)
        vol.GetMapper().SetClippingPlanes(planes)

    boxWidget.SetInputData(vol.GetMapper().GetInput())
    boxWidget.OutlineCursorWiresOn()
    boxWidget.GetSelectedOutlineProperty().SetColor(1, 0, 1)
    boxWidget.GetOutlineProperty().SetColor(0.2, 0.2, 0.2)
    boxWidget.GetOutlineProperty().SetOpacity(0.7)
    boxWidget.SetPlaceFactor(1.0)
    boxWidget.PlaceWidget()
    boxWidget.InsideOutOn()
    boxWidget.AddObserver("InteractionEvent", clipVolumeRender)

    renderer.ResetCamera()
    boxWidget.On()
    interactor.Start()

```

check out also [here](https://github.com/marcomusy/vtkplotter-examples/blob/master/vtkplotter_examples/basic/cutter.py).

---

<div class="post-metadata">

### Author: ![snehal](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@snehal](https://discourse.vtk.org/u/snehal)
#### Post date: [December 27, 2019, 4:30am UTC](https://discourse.vtk.org/t/vtkcutter/2337/3 "2019-12-27T04:30:30Z")

</div>

Thank you for your reply, definately i will try this.  
But basically i am looking for the cutter function which cuts the 3d volume dicom image,  
which is exactly done in ITK-SNAP.

---

<div class="post-metadata">

### Author: ![snehal](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@snehal](https://discourse.vtk.org/u/snehal)
#### Post date: [December 27, 2019, 12:17pm UTC](https://discourse.vtk.org/t/vtkcutter/2337/4 "2019-12-27T12:17:06Z")

</div>

When i used vtkplotter.addons.addCutterTool( volume ) it gives me following error :

AttributeError Traceback (most recent call last) in  
----\> 1 vtkplotter.addons.addCutterTool(volume)

c:\users\s.jadhav\appdata\local\continuum\anaconda3\envs\cad\lib\site-packages\vtkplotter\addons.py in addCutterTool(actor)  
527 “”"  
528 if isinstance(actor, vtk.vtkVolume):  
–\> 529 return \_addVolumeCutterTool(actor)  
530 elif isinstance(actor, vtk.vtkImageData):  
531 from vtkplotter import Volume

c:\users\s.jadhav\appdata\local\continuum\anaconda3\envs\cad\lib\site-packages\vtkplotter\addons.py in \_addVolumeCutterTool(vol)  
600 def \_addVolumeCutterTool(vol):  
601 vp = settings.plotter\_instance  
–\> 602 if not vp.renderer:  
603 save\_int = vp.interactive  
604 vp.show(interactive=0)

AttributeError: ‘NoneType’ object has no attribute ‘renderer’

---

<div class="post-metadata">

### Author: ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)
#### Post date: [December 27, 2019, 1:48pm UTC](https://discourse.vtk.org/t/vtkcutter/2337/5 "2019-12-27T13:48:23Z")

</div>

Please submit an issue [here](https://github.com/marcomusy/vtkplotter/issues).
