Scaling tube radius by distance to camera

Hi,
I would like to scale the radius of vtkTubeFilter in my vtkPolyDataMapper the same way I’m able to scale the radius of vtkSphereSource in my vtkGlyph3DMapper, with respect to vtkDistanceToCamera.

In the TubesWithVaryingRadiusAndColors example I see how a scalar array gets added to the polydata. But how can I do this with the ‘DistanceToCamera’ array generated by vtkDistanceToCamera since this connection occurs at the mapper level?

This is really easy in python… particularly easy with vtki:

import vtki
from vtki import examples
import vtk

# Create a line to use
alg = vtk.vtkLineSource()
alg.SetPoint1(0,0,0)
alg.SetPoint2(10,10,5)
alg.Update()
line = vtki.wrap(alg.GetOutput())

# Create a scene
p = vtki.Plotter()

# Add the line
p.add_mesh(line, line_width=10)

# Set the camera location
p.isometric_view()
p.camera_set = True

# Use the vtkDistanceToCamera filter
alg = vtk.vtkDistanceToCamera()
alg.SetRenderer(p.renderer)
alg.SetInputDataObject(line)
alg.Update()
# Make a tube with warped radius
updated = vtki.wrap(alg.GetOutput())
updated.set_active_scalar('DistanceToCamera')
tube = updated.tube(scalars='DistanceToCamera')

# Render the tube!
p.add_mesh(tube)

# display it all
p.show()