Issue importing Attribute map with Python


#1

This script aims to copy blendshape information from one mesh to another using an existing attribute map. What I’ve been able to do is use maya.mel to use mel commands to manually import an attribute map in .iff format. When I try to write it using python I can’t seem to get the map to import:

import maya.cmds as cmds
import maya.mel as mel
import os
facNum = 1
maleWeightsPath = “X:/Private/DATA/SCRIPTS/NeckFixer/Tetra/NeckFixer_WeightsMap.iff”
pathCheck = os.path.isfile(maleWeightsPath)
print pathCheck
selObj = cmds.ls( sl = True )
for facs in selObj[1:]:
try:
cmds.select( clear = True )
cmds.blendShape( selObj[0], selObj[facNum] )
cmds.blendShape( selObj[facNum], edit = True, w = [0, 1.0] )
cmds.select( selObj[facNum] )
mel.eval(‘ArtPaintBlendShapeWeightsTool;’)
mel.eval(‘artAttrInitPaintableAttr;’)
mel.eval(‘artBlendShapeTargetIndex;’)
mel.eval(‘artAttrPaintOperation artAttrCtx Replace;’)
ctx = cmds.currentCtx()
print ctx
cmds.ArtPaintBlendShapeWeightsTool( ctx, e = True, ifl = maleWeightsPath, ifm = ‘luminance’ )
cmds.duplicate()
mel.eval(‘ExportSelection;’)
#cmds.delete( selObj[0], selObj[facNum] )
facNum += 1
except IndexError:
print ‘Must select 2 or more meshes.’

ctx = cmds.currentCtx() returns artBlendShapeWeightsContext

cmds.ArtPaintBlendShapeWeightsTool( ctx, e = True, ifl = maleWeightsPath, ifm = ‘luminance’ ) doesn’t error, but it doesn’t import the map, instead it just continues through the script.

Anyone have any ideas as to why the map won’t import? I’ve heard a lot of people have had issues with scripting tools for the Artisan tools in Maya so perhaps this is just broken, though hopefully not.

Thanks!


#2

Solved my own issue,

instead of cmds.ArtPaintBlendShapeWeightsTool I used cmds.artAttrCtx

cmds.artAttrCtx( ctx, e = True, ifl = maleWeightsPath, ifm = ‘luminance’ )

:slight_smile: