Blender Python api 顶点、边和面选择
使用我从 获得的以下代码https://blender.stackexchange.com/questions/43127/how-do-i-select-specific-vertices-in-blender-using-python-script。我可以选择顶点,但是当我取消注释边缘或面并注释顶点时,它不起作用。我只是猜测了“edges”和“facees”的拼写,但它正确吗?
import bpy
#clear scene, make mesh
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, align='WORLD', location=(0, 0, 0), rotation=(1.5708, 1.5708, 0))
obj = bpy.data.objects["Cube"]
#select vertex
obj = bpy.context.active_object
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_mode(type="VERT")
#bpy.ops.mesh.select_mode(type="EDGE")
#bpy.ops.mesh.select_mode(type="FACE")
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')
obj.data.vertices[5].select = True
#obj.data.edges[1].select = True
#obj.data.faces[1].select = True
bpy.ops.object.mode_set(mode = 'EDIT')
Using the following code which I got from https://blender.stackexchange.com/questions/43127/how-do-i-select-specific-vertices-in-blender-using-python-script. I can get vertices to select but when I uncomment for edged or faces and comment for vertices it doesn't work. I just guessed at the spelling for edges and facees but is it correct?
import bpy
#clear scene, make mesh
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, align='WORLD', location=(0, 0, 0), rotation=(1.5708, 1.5708, 0))
obj = bpy.data.objects["Cube"]
#select vertex
obj = bpy.context.active_object
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_mode(type="VERT")
#bpy.ops.mesh.select_mode(type="EDGE")
#bpy.ops.mesh.select_mode(type="FACE")
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')
obj.data.vertices[5].select = True
#obj.data.edges[1].select = True
#obj.data.faces[1].select = True
bpy.ops.object.mode_set(mode = 'EDIT')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终用“多边形”一词替换了“面”一词,并且它起作用了。
I eventually replaced the word 'face' with the word 'polygons' and it worked.
在编辑模式下,Blender 使用网格的“副本”,该副本在您退出此模式之前不会保存。在对象模式下,更改是立即的。
In edit mode Blender works with a 'copy' of the mesh that is not saved until you exit this mode. In object mode the changes are immediate.