# problem in using vtkextrusion for 3D files

**URL:** https://discourse.vtk.org/t/problem-in-using-vtkextrusion-for-3d-files/5236
**Category:** Support
**Created:** [February 23, 2021, 2:13pm UTC](https://discourse.vtk.org/t/problem-in-using-vtkextrusion-for-3d-files/5236 "2021-02-23T14:13:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Amir\_Hossein\_Zeydi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amir_hossein_zeydi/32/2161_2.png) [@Amir\_Hossein\_Zeydi](https://discourse.vtk.org/u/Amir_Hossein_Zeydi)
#### Post date: [February 23, 2021, 2:13pm UTC](https://discourse.vtk.org/t/problem-in-using-vtkextrusion-for-3d-files/5236/1 "2021-02-23T14:13:28Z")

</div>

I used vtkextrusion to extrude a 3D STL of bone. But after using the code below it just duplicated it for me.

this is my code:

```
import vtk

filename = "the file"

#First STL file
reader = vtk.vtkSTLReader()
reader.SetFileName(filename)

        
extrude = vtk.vtkLinearExtrusionFilter()
extrude.SetInputConnection(reader.GetOutputPort())
extrude.SetExtrusionTypeToNormalExtrusion()
extrude.SetVector(0, 50, 1)
extrude.Update()

mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
    mapper.SetInput(extrude.GetOutput())
else:
    mapper.SetInputConnection(extrude.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mapper)

# Create a rendering window and renderer
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
 
# Create a renderwindowinteractor
iren = vtk.vtkRenderWindowInteractor()
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballActor())
iren.SetRenderWindow(renWin)

# Assign actor to the renderer
ren.AddActor(actor)

# Enable user interface interactor
ren.ResetCamera()
iren.Initialize()
renWin.Render()
iren.Start()

```

and here is the output

 ![image](https://discourse.vtk.org/uploads/default/original/2X/2/201ff1fce3f10c00a40f167782fd4e5cc1c34e3b.png)

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 23, 2021, 4:36pm UTC](https://discourse.vtk.org/t/problem-in-using-vtkextrusion-for-3d-files/5236/2 "2021-02-23T16:36:33Z")

</div>

STL files cannot store surface normals. You need to insert a vtkPolyDataNormals between the STL reader and the extrusion filter. Note that you may get self-intersecting mesh near sharp edges. If you really need to grow a shell around the entire bone then it is more robust to do the margin growing on the segmentation and then convert to mesh.

If you plan to generate 3D-printable patient-specific surgical guides then you may be interested in participating in this project: [https://github.com/lassoan/SlicerBoneReconstructionPlanner](https://github.com/lassoan/SlicerBoneReconstructionPlanner). It is being actively developed, but we can already create surgical plan and generate cutting guides like this automatically:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/3/38a46e5fc5cc556ab54d37c8bbd45fb5b6259a95.jpeg)
