简体   繁体   中英

Curve object is not callable error vPython

I'm new to vPython and Python in general and got this error when I was trying to create a catenoid. I was able to call a curve object earlier in the code that works fine but when I tried to do it a second time using the exact same syntax I get the aforementioned error. I imagine it is a fairly simple error but Id really appreciate if someone could help me out. The error occurs on line 11.

from visual import *
import math
curve=curve(color=color.green)
thStep=math.pi/1000
c=10 
theta=0
z=4 
a=.5
t=-z 
tStep=0.1
cur=curve(color=color.blue)
while theta<=(2*math.pi):
 x=c*(math.cosh(z/c))*math.cos(theta)
 y=c*(math.cosh(z/c))*math.sin(theta)
 curve.append(pos=(x,y,z))
 while t<=z:
    cur.append(pos=(t,a*math.cosh(t/a),0))
    t +=tStep
theta += thStep

Your issue is with this line:

curve=curve(color=color.green)

You are assigning curve to something else and thus, it no longer points to the function. When you use curve again, you are referencing the value you assigned to it, which is not a function and so, not callable.

To help fix this issue, you should use a separate name for the variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM