1
$\begingroup$

How to convert selected vertices in edit mode to mask in sculpt mode? Test

$\endgroup$
3
$\begingroup$
import bpy
import bmesh

Om = bpy.context.object.data
vertm = [v.select for v in Om.vertices]
bm = bmesh.new()
bm.from_mesh(Om)
if not bm.verts.layers.paint_mask:
    m = bm.verts.layers.paint_mask.new()
else:
    m = bm.verts.layers.paint_mask[0]
for i, i2 in zip(bm.verts, vertm):
    i[m] = i2
bm.to_mesh(Om)
bm.clear()
Om.update()

this will work in Object and Sculpt modes. Not while in Edit mode.

| improve this answer | |
$\endgroup$
  • 2
    $\begingroup$ I think it would be useful to add some further description or comments to explain how this works. $\endgroup$ – Ray Mairlot Apr 10 '18 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.