# How to define a single scalar as an input parameter for Programmable Filter

I would like to create a custom filter consisting of the programmable filter and others. The programmable filter has a hardcoded parameter in it, that I would like to define as an input parameter. Is that possible?

As an example, let’s take the helix code from the tutorials (below). Is it possible to have `length` be an input field for the filter instead of it being hardcoded?

``````#This script generates a helix curve.
#This is intended as the script of a 'Programmable Source'
import math

numPts = 80 # Points along Helix
length = 8.0 # Length of Helix
rounds = 3.0 # Number of times around

#Get a vtk.PolyData object for the output
pdo = self.GetPolyDataOutput()

#This will store the points for the Helix
newPts = vtk.vtkPoints()
for i in range(0, numPts):
#Generate the Points along the Helix
x = i*length/numPts
y = math.sin(i*rounds*2*math.pi/numPts)
z = math.cos(i*rounds*2*math.pi/numPts)
#Insert the Points into the vtkPoints object
#The first parameter indicates the reference.
#value for the point. Here we add them sequentially.
#Note that the first point is at index 0 (not 1).
newPts.InsertPoint(i, x,y,z)

#Add the points to the vtkPolyData object
#Right now the points are not associated with a line -
#it is just a set of unconnected points. We need to
#create a 'cell' object that ties points together
#to make a curve (in this case). This is done below.
#A 'cell' is just an object that tells how points are
#connected to make a 1D, 2D, or 3D object.
pdo.SetPoints(newPts)

#Make a vtkPolyLine which holds the info necessary
#to create a curve composed of line segments. This
#really just hold constructor data that will be passed
#to vtkPolyData to add a new line.
aPolyLine = vtk.vtkPolyLine()

#Indicate the number of points along the line
aPolyLine.GetPointIds().SetNumberOfIds(numPts)
for i in range(0,numPts):
#Add the points to the line. The first value indicates
#the order of the point on the line. The second value
#is a reference to a point in a vtkPoints object. Depends
#on the order that Points were added to vtkPoints object.
#Note that this will not be associated with actual points
#until it is added to a vtkPolyData object which holds a
#vtkPoints object.
aPolyLine.GetPointIds().SetId(i, i)

#Allocate the number of 'cells' that will be added. We are just
#adding one vtkPolyLine 'cell' to the vtkPolyData object.
pdo.Allocate(1, 1)

#Add the poly line 'cell' to the vtkPolyData object.
pdo.InsertNextCell(aPolyLine.GetCellType(), aPolyLine.GetPointIds())

#The Helix is ready to plot! Click 'Apply'.
``````

Yes, it is possible. But you’ll have to write your slightly differently using the PythonAlgorithm. This will allow you to add parameters and gui interface to your algorithm.

section 4.4 Python Algorithm.