3D surface animation the diameter of a wire/cylinder

Hello,

I am trying to recreate a 3D model of a wire and add a slider for one the axis.
I am able to this with the code below (sorry for the length, I didnt have time to remove/correct things yet since I am still in the first part of my project).
As I did not see anything like the range slider, I tried using sliders with for each frame a different part of the wire.
However I cant get this to work and I cant find the error. I based this code on codes that I found:


–
import plotly.graph_objs as go
import random
import plotly.plotly as py
import numpy as np
MaxDiameter=s = np.random.uniform(2.85,2.95,1000)
MinDiameter=s = np.random.uniform(2.75,2.85,1000)
x=[]
y=[]
z=[]

xx=[]
yy=[]
zz=[]

xxlist=[]
yylist=[]
zzlist=[]
pixels=20
t = np.linspace(0, 2 * np.pi, pixels)#gives 2*20
iteration=0
iterationadd=1
seconditer=0
framesize=20

for Max,Min in zip(MaxDiameter,MinDiameter):
if iteration<(framesize+seconditer) and iteration>=(0+seconditer):
print(iteration)
us = np.linspace(0, 2 * np.pi, pixels)
zs = np.linspace(iteration,iteration+iterationadd, 2)
iteration+=iterationadd
us, zs = np.meshgrid(us, zs)

#     xs = (Dia+Ovality) * np.cos(us)
#     ys = (Dia-Ovality) * np.sin(us)
    xs = Max* np.cos(us)
    ys = Min * np.sin(us)
    x.append(xs)
    y.append(ys)
    z.append(zs)
else:
    print('hmm ',iteration)
    seconditer+=framesize
    print('second',seconditer)

xx=xs*0

yy=ys*0

zz=ys*0

    for a,s,d,leng in zip(x,y,z,range(len(z))):
        if leng==0:
            zz=d
            yy=s
            xx=a
            continue
        zz=np.concatenate((zz,d))
        yy=np.concatenate((yy,s))
        xx=np.concatenate((xx,a))
    zz,xx=xx,zz#swap
    xxlist.append(xx)
    yylist.append(yy)
    zzlist.append(zz)
    x=[]
    y=[]
    z=[]

    xx=[]
    yy=[]
    zz=[]

for a,s,d,leng in zip(x,y,z,range(len(z))):
if leng==0:
zz=d
yy=s
xx=a
continue
zz=np.concatenate((zz,d))
yy=np.concatenate((yy,s))
xx=np.concatenate((xx,a))
zz,xx=xx,zz#swap
xxlist.append(xx)
yylist.append(yy)
zzlist.append(zz)
x=[]
y=[]
z=[]
xx=[]
yy=[]
zz=[]
surface = go.Surface(x=xxlist[1], y=yylist[1], z=zzlist[1])#cartensian coordiantes
data = [surface]

datalist=[]
for v in range(len(xxlist)):
surface = go.Surface(x=xxlist[v], y=yylist[v], z=zzlist[v])
thedata = [surface]
datalist.append(thedata)
theframes=[dict(data= datalist[k],
traces= [0],
name=‘frame{}’.format(k)
) for k in range(len(xxlist))]

sliders=[dict(steps= [dict(method= ‘animate’,
args= [[ ‘frame{}’.format(k) ],
dict(mode= ‘immediate’,
frame= dict( duration=50, redraw= False ),
transition=dict( duration= 0)
)
]
) for k in range(len(xxlist))],
transition= dict(duration= 0 ),
x=0,
y=0,
currentvalue=dict(font=dict(size=12),
prefix='Time: ',
visible=True,
xanchor= ‘center’
),
len=1.0))
]

rangehx=4
rangelx=-4
layout = go.Layout(
title=‘Wire’,
scene=dict(
xaxis=dict(
gridcolor=‘rgb(255, 255, 255)’,
zerolinecolor=‘rgb(255, 255, 255)’,
showbackground=True,
backgroundcolor=‘rgb(230, 230,230)’,
yaxis=dict(
gridcolor=‘rgb(255, 255, 255)’,
zerolinecolor=‘rgb(255, 255, 255)’,
showbackground=True,
backgroundcolor=‘rgb(230, 230,230)’,
range=[rangelx,rangehx]
),
zaxis=dict(
gridcolor=‘rgb(255, 255, 255)’,
zerolinecolor=‘rgb(255, 255, 255)’,
showbackground=True,
backgroundcolor=‘rgb(230, 230,230)’,
range=[rangelx,rangehx]
),

),
updatemenus=[dict(type='buttons', showactive=False,
            y=0,
            x=1.15,
            xanchor='right',
            yanchor='top',
            pad=dict(t=0, r=10),
            buttons=[dict(label='Play',
                          method='animate',
                          args=[None, 
                                dict(frame=dict(duration=30, 
                                                redraw=True),
                                     transition=dict(duration=0),
                                     fromcurrent=True,
                                     mode='immediate'
                                    )
                               ]
                         )
                    ]
           )
      ],
sliders=sliders,

fig = go.Figure(data=data, layout=layout,frames=theframes)
py.iplot(fig, filename=‘Diameter3’)