# Get normals coordinates

**URL:** https://discourse.vtk.org/t/get-normals-coordinates/5124
**Category:** Support
**Created:** [February 2, 2021, 1:00pm UTC](https://discourse.vtk.org/t/get-normals-coordinates/5124 "2021-02-02T13:00:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Anastasiia](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@Anastasiia](https://discourse.vtk.org/u/Anastasiia)
#### Post date: [February 2, 2021, 1:00pm UTC](https://discourse.vtk.org/t/get-normals-coordinates/5124/1 "2021-02-02T13:00:22Z")

</div>

Hi VTK community,

Is there any options to get X,Y,Z coordinates of the cell normals?

Currently I have the following code:

normals = vtk.vtkPPolyDataNormals()  
normals.SetInputConnection(decimate.GetOutputPort())

normals.ComputeCellNormalsOn()

normals.SplittingOff()  
normals.FlipNormalsOff()  
normals.ConsistencyOn()  
normals.AutoOrientNormalsOn()  
normals.Update()

For my further processing steps I need to get coordinates (ot at least angle of the normals). I’ve found vtkDeflectNormals() class, however, I get this error with it: AttributeError: module ‘vtkmodules.all’ has no attribute ‘vtkDeflectNormals’

---

<div class="post-metadata">

### Author: ![DFlyer](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dflyer/32/1598_2.png) [@DFlyer](https://discourse.vtk.org/u/DFlyer)
#### Post date: [February 2, 2021, 5:40pm UTC](https://discourse.vtk.org/t/get-normals-coordinates/5124/2 "2021-02-02T17:40:32Z")

</div>

Normals are computed as float array and stored in cell data.

I don’t have the python code, in C++ one can do this

> ```
> vtkFloatArray* normalsFloat = vtkFloatArray::SafeDownCast( polydata->GetCellData()->GetNormals() );
> 
> ```

---

<div class="post-metadata">

### Author: ![Anastasiia](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@Anastasiia](https://discourse.vtk.org/u/Anastasiia)
#### Post date: [February 3, 2021, 8:04am UTC](https://discourse.vtk.org/t/get-normals-coordinates/5124/3 "2021-02-03T08:04:15Z")

</div>

Thanks for your comment, I’ve tried your solution, however it works only with VTK primitives such as sphere, for example. When I use polydata-\>GetCellData()-\>GetNormals() with STL file, the result is None:

filename = “loop.STL”  
source = vtk.vtkSTLReader()

source.SetFileName(filename)  
source.Update()

polydata = vtk.vtkPolyData()  
polydata.ShallowCopy(source.GetOutput())

normals = polydata.GetCellData().GetNormals()  
print(normals)

The result as I mentioned is None. I’ve tried different STL files here, but the problem persists. Is there any problem with my code or GetNormals() works only with primitives?

---

<div class="post-metadata">

### Author: ![DFlyer](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dflyer/32/1598_2.png) [@DFlyer](https://discourse.vtk.org/u/DFlyer)
#### Post date: [February 3, 2021, 8:22am UTC](https://discourse.vtk.org/t/get-normals-coordinates/5124/4 "2021-02-03T08:22:00Z")

</div>

Get the polydata from STL reader and compute the normal as you originally posted. If you don’t compute normal you cannot expect them to be there.

Cheers!

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [February 3, 2021, 11:35am UTC](https://discourse.vtk.org/t/get-normals-coordinates/5124/5 "2021-02-03T11:35:14Z")

</div>

To generate points at the (parametric) center of cells use vtkCellCenters
