Last active
August 29, 2015 14:14
-
-
Save nutti/5d3600ceeb1b6e1268de to your computer and use it in GitHub Desktop.
[Blender] オブジェクトの頂点・辺・面の選択順序を取得する方法 ref: http://qiita.com/nutti/items/384109ec6ed6d4a2e9f9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh # 追加でインポートが必要 | |
obj = bpy.context.active_object | |
bpy.ops.object.mode_set(mode='EDIT') # 処理はEDITモードで行う必要がある | |
bm = bmesh.from_edit_mesh(obj.data) | |
# blenderのバージョンが2.73以上の時に必要 | |
if bpy.app.version[0] >= 2 and bpy.app.version[1] >= 73: | |
bm.edges.ensure_lookup_table() | |
# 辺の選択順序を表示 | |
for e in bm.select_history: | |
if isinstance(e, bmesh.types.BMEdge) and e.select: | |
print(repr(e)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh # 追加でインポートが必要 | |
obj = bpy.context.active_object | |
bpy.ops.object.mode_set(mode='EDIT') # 処理はEDITモードで行う必要がある | |
bm = bmesh.from_edit_mesh(obj.data) | |
# blenderのバージョンが2.73以上の時に必要 | |
if bpy.app.version[0] >= 2 and bpy.app.version[1] >= 73: | |
bm.faces.ensure_lookup_table() | |
# 面の選択順序を表示 | |
for e in bm.select_history: | |
if isinstance(e, bmesh.types.BMFace) and e.select: | |
print(repr(e)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh # 追加でインポートが必要 | |
obj = bpy.context.active_object | |
bpy.ops.object.mode_set(mode='EDIT') # 処理はEDITモードで行う必要がある | |
bm = bmesh.from_edit_mesh(obj.data) | |
# blenderのバージョンが2.73以上の時に必要 | |
if bpy.app.version[0] >= 2 and bpy.app.version[1] >= 73: | |
bm.verts.ensure_lookup_table() | |
# 頂点の選択順序を表示 | |
for e in bm.select_history: | |
if isinstance(e, bmesh.types.BMVert) and e.select: | |
print(repr(e)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> for e in bm.select_history: | |
... if isinstance(e, bmesh.types.BMFace) and e.select: | |
... print(repr(e)) | |
<BMFace(0x108482cf0), index=4, totverts=4> | |
<BMFace(0x108482c80), index=2, totverts=4> | |
>>> | |
>>> for e in bm.select_history: | |
... if isinstance(e, bmesh.types.BMEdge) and e.select: | |
... print(repr(e)) | |
<BMEdge(0x11241f380)>, index=11, verts=(0x10849a960/6, 0x10849a998/7)> | |
<BMEdge(0x11241f1a0)>, index=5, verts=(0x10849a880/2, 0x10849a8b8/3)> | |
>>> | |
>>> for e in bm.select_history: | |
... if isinstance(e, bmesh.types.BMVert) and e.select: | |
... print(repr(e)) | |
<BMVert(0x10849a960), index=6> | |
<BMVert(0x10849a8f0), index=4> | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment