# Issue with retrieving X-Coordinates from Contour Source using a Python Script

**URL:** https://discourse.paraview.org/t/issue-with-retrieving-x-coordinates-from-contour-source-using-a-python-script/13150
**Category:** ParaView Support
**Tags:** python, vtk
**Created:** [October 31, 2023, 6:45pm UTC](https://discourse.paraview.org/t/issue-with-retrieving-x-coordinates-from-contour-source-using-a-python-script/13150 "2023-10-31T18:45:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![flymouche](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/e0b2c6/32.png) [@flymouche](https://discourse.paraview.org/u/flymouche)
#### Post date: [October 31, 2023, 6:45pm UTC](https://discourse.paraview.org/t/issue-with-retrieving-x-coordinates-from-contour-source-using-a-python-script/13150/1 "2023-10-31T18:45:19Z")

</div>

Hello, I am encoutering issues with retrieving the X coordinates from a Contour Source. I have realized a Contour source using the following commands :

“contour1 = Contour(registrationName=‘Contour1’, Input=my\_input)  
contour1.ContourBy = [‘POINTS’, ‘my\_variable’]  
contour1.Isosurfaces = [0.5]  
contour1.PointMergeMethod = ‘Uniform Binning’”

I know that these commands succeded in creating a contour as the SaveData command works fine :

“SaveData(‘my\_output\_file\_name’, proxy=contour1, PointDataArrays=[‘Normals’,‘my\_variable’], FieldDataArrays=[ispatch’])”

It creates a csv that I can properly read and from which I can retrieve the X coordinates of the contour.  
I wish to retrieve the X coordinates dataset without passing through the generation of a CSV file.  
For this I have relentlessly been trying to descend through the “contour1” data structure to retrieve the X coordinates.

After multiple attempts I have finished by giving up after encountering the following situation :

- contour1.GetClientSideObject().GetOutputDataObject(0).GetPointData().GetArray(‘X\_Coordinates’) with no success. The error it raises is : ‘vtkmodules.vtkCommonDataModel.vtkMultiBlockDataSet’ has no attribute GetPointData.

- Since it is a MultiBlockDataSet, I have tried to descend into a “block”. But when I do contour1.GetClientSideObject().GetOutputDataObject(0).GetNumberOfBlocks it tells me that the number of block to descend into is 0. Which means that it is not “working” MultiBlockDataSet.

I have also tried other things that I do not remember anymore sadly. I wish to understand what it is that I am doing wrong.I have actually succeeded in retrieving the Area of the contour and the volume under the contour by using the threshold treatment. I just need to understand how I can possibly get the X coordinates of the points on the Contour.

It goes without saying that I am quite a newbie to vtk and python paraview.

Tank you very much for you attention.

---

<div class="post-metadata">

### Author: ![caladoa](https://discourse.paraview.org/user_avatar/discourse.paraview.org/caladoa/32/11322_2.png) [@caladoa](https://discourse.paraview.org/u/caladoa)
#### Post date: [October 31, 2023, 9:04pm UTC](https://discourse.paraview.org/t/issue-with-retrieving-x-coordinates-from-contour-source-using-a-python-script/13150/2 "2023-10-31T21:04:06Z")

</div>

I am not sure this would help, but I used the following to get the XYZ coordinates of the bounding box (only min/max values) for a VTK object (e.g. contour or threhsold) within a Programmable filter.

```
input0 = inputs[0]
f = vtk.vtkThreshold()
f.SetInputData(input0.VTKObject)
input1 = f.GetOutput()
[xmin,xmax,ymin,ymax,zmin,zmax] = input1.GetBounds()

```
