简体   繁体   English

如何在此循环中每次将y的值增加1

[英]How to increase the value of y by one every time on this loop

I am doing some basic Python in Blender and I want to add in a grid of cubes. 我在Blender中做一些基本的Python,我想添加一个多维数据集网格。 If you can imagine that as count is 5 this creates a 5x5 grid of 25 cubes. 如果您可以想象,当count为5时,这将创建一个包含25个立方体的5x5网格。 However, I've got the code working so that the x axis increases each time but don't know how to edit the nested for loop so it does the same and increases along the y, as at the moment all that happens is you get a 5-long line of cubes with 5 more cubes layered on top of it. 但是,我已经使代码工作,以便x轴每次都增加但不知道如何编辑嵌套的for循环,所以它做同样的事情并沿着y增加,因为当时发生的一切都是你得到的一个5长的立方体系列,上面有5个立方体。

#how many cubes you want to add on each axis
count = 5

for i in range (0,count):
    for cube_instance in range(0,count):
        x = 1
        y = 1
        z = 0
        bpy.ops.mesh.primitive_cube_add(location=(x * cube_instance + 1,y,z))

Thanks for any help. 谢谢你的帮助。

我猜y = 1 + i应该做的伎俩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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