# Setting an attribute with a variable

**URL:** https://discourse.paraview.org/t/setting-an-attribute-with-a-variable/12130
**Category:** ParaView Support
**Created:** [May 20, 2023, 10:07am UTC](https://discourse.paraview.org/t/setting-an-attribute-with-a-variable/12130 "2023-05-20T10:07:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kevin\_Arden](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kevin_arden/32/11637_2.png) [@Kevin\_Arden](https://discourse.paraview.org/u/Kevin_Arden)
#### Post date: [May 20, 2023, 10:07am UTC](https://discourse.paraview.org/t/setting-an-attribute-with-a-variable/12130/1 "2023-05-20T10:07:51Z")

</div>

I am using pvpython script to create a plot, it works well when I hard code the value, but I want to use a variable. I successfully pass the variable, verified by the print command

```auto
# create a new 'Plot Over Line'
print("xvalue=", xvalue)
plotOverLine1 = PlotOverLine(registrationName='PlotOverLine1', Input=step_t0001vtu)
plotOverLine1.Point1 = [xvalue, 0.0, 0.0]
plotOverLine1.Point2 = [xvalue, 0.096, 0.0]

```

but the plotOverLine1.Point1 = [xvalue, 0.0, 0.0] line doesn’t except the variable

`xvalue= 0.0036`

```auto
Traceback (most recent call last):
  File "C:\featest\ElmerFEM_Colab\ParaviewScripts\plotline.py", line 109, in <module>
    plotOverLine1.Point1 = [xvalue, 0.0, 0.0]
  File "C:\Program Files\ParaView 5.11.0\bin\Lib\site-packages\paraview\servermanager.py", line 496, in __setattr__
    setter(self, value)
  File "C:\Program Files\ParaView 5.11.0\bin\Lib\site-packages\paraview\servermanager.py", line 2612, in setProperty
    return self.SetPropertyWithName(propName, value)
  File "C:\Program Files\ParaView 5.11.0\bin\Lib\site-packages\paraview\servermanager.py", line 355, in SetPropertyWithName
    prop.SetData(arg)
  File "C:\Program Files\ParaView 5.11.0\bin\Lib\site-packages\paraview\servermanager.py", line 879, in SetData
    self.SMProperty.SetElement(idx, val)
TypeError: SetElement argument 2:

```

Any suggestions?

---

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [May 24, 2023, 5:11am UTC](https://discourse.paraview.org/t/setting-an-attribute-with-a-variable/12130/2 "2023-05-24T05:11:27Z")

</div>

Is xvalue a float?

---

<div class="post-metadata">

### Author: ![Kevin\_Arden](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kevin_arden/32/11637_2.png) [@Kevin\_Arden](https://discourse.paraview.org/u/Kevin_Arden)
#### Post date: [May 24, 2023, 8:11am UTC](https://discourse.paraview.org/t/setting-an-attribute-with-a-variable/12130/3 "2023-05-24T08:11:46Z")

</div>

I forced it to be a float and now it works. Thanks
