我正在尝试“参数化”vpython sphere命令的属性。除了颜色属性外,一切正常。
到目前为止的故事: -
for i in range(53):
planet = objekt[i]
col = colour[i]
col = 'vector'+col[1:3]+','+col[3:4]+','+col[4:6]
print planet, col
planet = sphere(pos=vector(xcoord[i]*KM, ycoord[i]*KM, zcoord[i]*KM),
radius=radii[i], color=col)
其中,objekt是一个行星体列表,颜色是n,n,n格式的颜色列表,其中n可以是0或1。
我收到错误消息: -
Sun vector(1,1,0)
Traceback (most recent call last):
File "C:\Python27\Planet Orbits\SolarSystem-MajorandMinorPlanets(b).py",
line 66
planet = sphere(pos=vector(xcoord[i]*KM, ycoord[i]*KM, zcoord[i]*KM),
radius=radii[i], color=col)
File "C:\Python27\Lib\site-packages\visual_common\primitives.py", line 93,
in __init__
self.process_init_args_from_keyword_dictionary( keywords )
File "C:\Python27\Lib\site-packages\visual_common\primitives.py", line
192, in process_init_args_from_keyword_dictionary
self.color = keywords['color']
ArgumentError: Python argument types in
None.None(sphere, str)
did not match C++ signature:
None(class cvisual::primitive {lvalue}, class cvisual::rgb)
>
答案 0 :(得分:0)
您构造了一个字符串,并试图在需要实际向量的地方使用它。你需要这样做:
col = vector(xcolor,ycolor,zcolor)