-
-
Save Taremin/434207d712afd97b08135707c5b5e8c6 to your computer and use it in GitHub Desktop.
アクティブオブジェクトのシェイプキーの影響下にある頂点を選択する
This file contains 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 numpy | |
obj = bpy.context.active_object | |
bpy.ops.object.mode_set(mode="OBJECT") | |
vlen = len(obj.data.vertices) | |
selected = numpy.zeros(vlen, dtype=bool) | |
obj.data.vertices.foreach_get("select", selected) | |
obj.data.polygons.foreach_set("select", numpy.zeros(len(obj.data.polygons), dtype=bool)) | |
obj.data.edges.foreach_set("select", numpy.zeros(len(obj.data.edges), dtype=bool)) | |
vco = numpy.empty((vlen, 3), dtype=numpy.float32) | |
obj.data.vertices.foreach_get("co", vco.ravel()) | |
for key_block in obj.data.shape_keys.key_blocks: | |
if key_block == key_block.relative_key: | |
continue | |
points = numpy.empty((vlen, 3), dtype=numpy.float32) | |
key_block.points.foreach_get("co", points.ravel()) | |
selected[numpy.where(vco != points)[0]] = True | |
obj.data.vertices.foreach_set("select", selected) | |
bpy.ops.object.mode_set(mode="EDIT") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
追加選択にしない場合は9行目はコメントアウトする
# obj.data.vertices.foreach_get("select", selected)