Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 《搅拌机与蟒蛇》中的困境_Python_Blender - Fatal编程技术网

Python 《搅拌机与蟒蛇》中的困境

Python 《搅拌机与蟒蛇》中的困境,python,blender,Python,Blender,我不熟悉blender和python。因此,我尝试一些例子,看看它们是否有效 但是我在尝试运行脚本时遇到了一个问题 AttributeError:“Vector”对象没有属性“pop” 我研究了一下互联网,却什么也没发现。这是关于“pop”或搅拌机甚至python的问题吗 有时python会警告我“pop”超出范围。有人能就如何解决这个问题提出建议吗?这是我搅拌机里的脚本 导入bpy 当前对象=bpy.context.active对象 打印(“=”*40) 对于当前_obj.data.poly

我不熟悉blender和python。因此,我尝试一些例子,看看它们是否有效

但是我在尝试运行脚本时遇到了一个问题

AttributeError:“Vector”对象没有属性“pop”

我研究了一下互联网,却什么也没发现。这是关于“pop”或搅拌机甚至python的问题吗

有时python会警告我“pop”超出范围。有人能就如何解决这个问题提出建议吗?这是我搅拌机里的脚本

导入bpy
当前对象=bpy.context.active对象
打印(“=”*40)
对于当前_obj.data.polygons中的面:
顶点在面=面。顶点[:]
打印(“面索引”,面索引)
打印(“正常”,面部。正常)
对于垂直面中的垂直面:
打印(“垂直”,垂直,“垂直坐标”,当前对象数据.vertexts[vert].co)
打印(“=”*40)
坐标=当前对象数据顶点[vert].co
打印(“坐标=,坐标.pop(2))
fo=打开(“foo.txt”、“rw+”)
打印(“文件名:”,fo.Name)
#这是一号线
#这是二线
#这是第三线
#这是第四线
#这是第五线
str=“这是第六行”
fo.seek(0,2)
line=fo.write(str)
fo.seek(0,0)
对于范围(6)中的索引:
line=fo.next()
打印(“行号%d-%s”%(索引,行))
fo.close()
.pop(x)
是Python
列表的一种方法,它从索引x处的列表中删除并返回一个值

这使
坐标
成为矢量对象:

coordinate = current_obj.data.vertices[vert].co
这将
坐标
视为
列表

print("coordinate = ", coordinate.pop(2))
您可以在此处阅读
pop()
方法:

坐标是一个向量,pop()从列表中删除一项。您可能希望更改向量值,但从向量中删除项是没有意义的

Blender提供了几种访问向量中数据的方法-

# like an array
coordinate.[0]
# most will contain 3 items but 4d Vectors are used in some situations.
len(coordinate)
# get a specific item
coordinate.y
# get a combination of elements - many variations available - xyz zyx yzx ....
coordinate.xyz
# each of these can be returned as a tuple instead of a vector
coordinate.to_tuple()
coordinate.xyz.to_tuple()
coordinate = current_obj.data.vertices[vert].co
print("coordinate = ", coordinate.pop(2))
# like an array
coordinate.[0]
# most will contain 3 items but 4d Vectors are used in some situations.
len(coordinate)
# get a specific item
coordinate.y
# get a combination of elements - many variations available - xyz zyx yzx ....
coordinate.xyz
# each of these can be returned as a tuple instead of a vector
coordinate.to_tuple()
coordinate.xyz.to_tuple()