Hello! Thank you so much for your quick reply!
Effectively I had not understood this system of properties. Now there's no error, but the right targetShape is still not selected. This always happens when maya has just been opened and has no tools loaded. As soon as you try a second time, it works (even if it's with an unrelated tool).
I've even tried another way of modifying the targetShape selection, but nothing works.
cmds.select(mesh)
if not cmds.artAttrCtx(“artAttrBlendShapeContext”, q=True, exists=True):
cmds.artAttrCtx(“artAttrBlendShapeContext”, i1=“paintBlendshape.png”, whichTool=“blendShapeWeights”)
if not cmds.artAttrCtx(“artBlendShapeSelectTarget”, q=True, exists=True):
mel.eval('source “artAttrBlendShapeProperties”')
shape = cmds.textScrollList(“tsl”, query=True, selectItem=True)[0].split(“.”)[1]
cmds.artAttrCtx(“artAttrBlendShapeContext”, e=True, toolOnProc='artBlendShapeSelectTarget artAttrCtx “{}”;'.format(shape))
cmds.ArtPaintBlendShapeWeightsTool()
cmds.toolPropertyWindow()
It's not a major bug, as it'll only happen in a few cases, but I wanted to try and fix it anyway.