コード例 #1
0
def artAttrCtx(*args, **kwargs):
    res = cmds.artAttrCtx(*args, **kwargs)
    wraps = _factories.simpleCommandWraps['artAttrCtx']
    for func, wrapCondition in wraps:
        if wrapCondition.eval(kwargs):
            res = func(res)
            break
    return res
コード例 #2
0
 def overwriteSelected(self, mapsTreeView, sourceVar, *args):
     selItem = cmds.treeView(mapsTreeView, query=True, si=True)
     greenlight = False
     for k0, v0 in self.global_work_space['miscData']['mapOps'][
             'crt_scene_maps'].items():
         if k0 == selItem[0]:
             greenlight = True
             selItemObj = v0
     if greenlight == False:
         print('match not found for ' + selItem[0])
     else:
         baseMesh = cmds.listConnections(selItemObj.parent_node +
                                         '.outputGeometry[0]')
         baseMesh = self.find_basemesh_nodetype(baseMesh)
         vertsNo = int(cmds.polyEvaluate(baseMesh, v=True))
         if selItemObj.map_type == 'blend':
             cmds.setToolTo('artAttrBlendShapeContext')
             pm.mel.artBlendShapeSelectTarget('artAttrCtx',
                                              selItemObj.inf_or_tgt)
             for vtxNo in range(vertsNo):
                 vtxKey = '.vtx[' + str(vtxNo) + ']'
                 newVtxVal = float(self.global_work_space['miscData']
                                   ['mapOps'][sourceVar][vtxKey])
                 cmds.select(baseMesh[0] + vtxKey)
                 cmds.artAttrCtx('artAttrBlendShapeContext',
                                 edit=True,
                                 val=newVtxVal,
                                 opacity=1.0,
                                 sao="absolute")
                 cmds.artAttrCtx('artAttrBlendShapeContext',
                                 edit=True,
                                 clr=True)
         elif selItemObj.map_type == 'skn_clstr':
             for vtxNo in range(vertsNo):
                 vtxKey = '.vtx[' + str(vtxNo) + ']'
                 newVtxVal = float(self.global_work_space['miscData']
                                   ['mapOps'][sourceVar][vtxKey])
                 cmds.skinPercent(selItemObj.parent_node,
                                  baseMesh[0] + vtxKey,
                                  transformValue=(selItemObj.inf_or_tgt,
                                                  newVtxVal))
コード例 #3
0
def checkPaintingContext():
    """
    Checks the painting context to check that everything is in order
    """
    resetContext = False
    if cmds.artAttrCtx("artAttrColorPerVertexContext", exists=True):
        resetContext = False

    mel.eval("PaintVertexColorTool;")  # make sure the paint vertex context exists

    if resetContext:
        cmds.resetTool('artAttrColorPerVertexContext')
        cmds.artAttrPaintVertexCtx('artAttrColorPerVertexContext', stampProfile="gaussian", e=True)
コード例 #4
0
ファイル: ZvRadialBlendShape.py プロジェクト: Bumpybox/Tapp
def paintWeightsCmd(rbsNode, upperIdx):
	wAttr = '%s.it[%d].%s' % (rbsNode, upperIdx, _wAttr)
	pAttr = '%s.weightList[0].weights' % rbsNode

	# disconnect
	_disconnectPaintWeights(rbsNode)
	
	# copy and connect
	cmds.connectAttr(wAttr, pAttr, f=True)
	cmds.getAttr(pAttr, mi=True)
	cmds.disconnectAttr(wAttr, pAttr)
	cmds.connectAttr(pAttr, wAttr, f=True)

	# paint tool
	obj = cmds.listRelatives(cmds.deformer(rbsNode, q=True, g=True), p=True, pa=True)[0]
	cmds.select(obj)
	cmds.setToolTo(cmds.artAttrCtx(oaa='%s.%s.weights' % (_rbsNodeName, rbsNode)))
コード例 #5
0
def paintWeightsCmd(rbsNode, upperIdx):
    wAttr = '%s.it[%d].%s' % (rbsNode, upperIdx, _wAttr)
    pAttr = '%s.weightList[0].weights' % rbsNode

    # disconnect
    _disconnectPaintWeights(rbsNode)

    # copy and connect
    cmds.connectAttr(wAttr, pAttr, f=True)
    cmds.getAttr(pAttr, mi=True)
    cmds.disconnectAttr(wAttr, pAttr)
    cmds.connectAttr(pAttr, wAttr, f=True)

    # paint tool
    obj = cmds.listRelatives(cmds.deformer(rbsNode, q=True, g=True),
                             p=True,
                             pa=True)[0]
    cmds.select(obj)
    cmds.setToolTo(
        cmds.artAttrCtx(oaa='%s.%s.weights' % (_rbsNodeName, rbsNode)))
コード例 #6
0
def mirrorWeightsCmd(rbsNode, upperIdx):
    destIdx = upperIdx

    # get destination prefix
    destPrfx = _getTargetNameFromIdx(rbsNode, destIdx)[0]

    # ask for the source
    srcPrfx = cmds.layoutDialog(
        t='Mirror bulge weights',
        ui=lambda *x: _mirrorWeightsDialog(rbsNode, destPrfx))
    if len(srcPrfx) > 1:
        return

    # find the source index
    idxPrfxList = _getEyeIdxPrfxList(rbsNode)

    srcIdx = -1
    for lowerIdx, prfx in idxPrfxList:
        if prfx == srcPrfx:
            srcIdx = lowerIdx + 1
            break

    if srcIdx < 0:
        raise Exception, 'Cannot find the index of target %s' % srcPrfx

    # membership set
    objSetNode = _getMembershipSet(rbsNode)
    affectedVtxList = cmds.ls(cmds.sets(objSetNode, q=True) or [], fl=True)

    # find original shape
    obj = cmds.listRelatives(cmds.deformer(rbsNode, q=True, g=True),
                             p=True,
                             pa=True)[0]
    origShape = [
        s for s in cmds.listRelatives(obj, s=True, pa=True)
        if cmds.getAttr('%s.intermediateObject' % s)
    ][0]

    # get the original point position
    origAffectedVtxList = [
        '%s%s' % (origShape, vtx[vtx.rindex('.'):]) for vtx in affectedVtxList
    ]
    vtxCount = len(origAffectedVtxList)
    posList = cmds.xform(origAffectedVtxList, q=True, os=True, t=True)
    posList = [posList[i:i + 3] for i in xrange(0, len(posList), 3)]

    # create a symmetry map (it stores the indices of the opposite vertices)
    cmds.progressBar('mainProgressBar',
                     e=True,
                     beginProgress=True,
                     isInterruptable=False,
                     status='Generating symmetry map...',
                     maxValue=vtxCount)
    symmMap = [-1] * len(affectedVtxList)
    for i, pos in enumerate(posList):
        cmds.progressBar('mainProgressBar', e=True, step=1)
        # avoid doing the test twice for the opposite vertex
        if symmMap[i] != -1:
            continue

        oppIdx = -1
        minDistance = 1000000.0

        for j, otherPos in enumerate(posList):
            dist = (otherPos[0] + pos[0])**2 + (otherPos[1] - pos[1])**2 + (
                otherPos[2] - pos[2])**2
            if dist < minDistance:
                minDistance = dist
                oppIdx = j

        symmMap[i] = oppIdx
        symmMap[oppIdx] = i
    cmds.progressBar('mainProgressBar', e=True, endProgress=True)

    # disconnect paint weights
    _disconnectPaintWeights(rbsNode)

    srcAttr = '%s.it[%d].%s' % (rbsNode, srcIdx, _wAttr)
    destAttr = '%s.it[%d].%s' % (rbsNode, destIdx, _wAttr)
    pAttr = '%s.weightList[0].weights' % rbsNode

    # copy weights from source to paint
    cmds.connectAttr(srcAttr, pAttr, f=True)
    cmds.getAttr(pAttr, mi=True)
    cmds.disconnectAttr(srcAttr, pAttr)

    # connect paint to destination weights
    cmds.connectAttr(pAttr, destAttr, f=True)

    affectedWeightList = cmds.percent(rbsNode, affectedVtxList, q=True, v=True)

    # set weights
    cmds.progressBar('mainProgressBar',
                     e=True,
                     beginProgress=True,
                     isInterruptable=False,
                     status='Setting weights...',
                     maxValue=vtxCount)
    for i, vtx in enumerate(affectedVtxList):
        cmds.progressBar('mainProgressBar', e=True, step=1)
        cmds.percent(rbsNode, vtx, v=affectedWeightList[symmMap[i]])
    cmds.progressBar('mainProgressBar', e=True, endProgress=True)

    # show the paint tool
    cmds.select(obj)
    cmds.setToolTo(
        cmds.artAttrCtx(oaa='%s.%s.weights' % (_rbsNodeName, rbsNode)))
コード例 #7
0
ファイル: ZvRadialBlendShape.py プロジェクト: Bumpybox/Tapp
def mirrorWeightsCmd(rbsNode, upperIdx):
	destIdx = upperIdx

	# get destination prefix
	destPrfx = _getTargetNameFromIdx(rbsNode, destIdx)[0]

	# ask for the source
	srcPrfx = cmds.layoutDialog(t='Mirror bulge weights', ui=lambda *x: _mirrorWeightsDialog(rbsNode, destPrfx))
	if len(srcPrfx) > 1:
		return

	# find the source index
	idxPrfxList = _getEyeIdxPrfxList(rbsNode)

	srcIdx = -1
	for lowerIdx, prfx in idxPrfxList:
		if prfx == srcPrfx:
			srcIdx = lowerIdx + 1
			break

	if srcIdx < 0:
		raise Exception, 'Cannot find the index of target %s' % srcPrfx

	# membership set
	objSetNode = _getMembershipSet(rbsNode)
	affectedVtxList = cmds.ls(cmds.sets(objSetNode, q=True) or [], fl=True)

	# find original shape
	obj = cmds.listRelatives(cmds.deformer(rbsNode, q=True, g=True), p=True, pa=True)[0]
	origShape = [s for s in cmds.listRelatives(obj, s=True, pa=True) if cmds.getAttr('%s.intermediateObject' % s)][0]

	# get the original point position
	origAffectedVtxList = ['%s%s' % (origShape, vtx[vtx.rindex('.'):]) for vtx in affectedVtxList]
	vtxCount = len(origAffectedVtxList)
	posList = cmds.xform(origAffectedVtxList, q=True, os=True, t=True)
	posList = [posList[i:i+3] for i in xrange(0, len(posList), 3)]

	# create a symmetry map (it stores the indices of the opposite vertices)
	cmds.progressBar('mainProgressBar', e=True, beginProgress=True, isInterruptable=False, status='Generating symmetry map...', maxValue=vtxCount)
	symmMap = [-1]*len(affectedVtxList)
	for i, pos in enumerate(posList):
		cmds.progressBar('mainProgressBar', e=True, step=1)
		# avoid doing the test twice for the opposite vertex
		if symmMap[i] != -1:
			continue

		oppIdx = -1
		minDistance = 1000000.0

		for j, otherPos in enumerate(posList):
			dist = (otherPos[0]+pos[0])**2 + (otherPos[1]-pos[1])**2 + (otherPos[2]-pos[2])**2
			if dist < minDistance:
				minDistance = dist
				oppIdx = j

		symmMap[i] = oppIdx
		symmMap[oppIdx] = i
	cmds.progressBar('mainProgressBar', e=True, endProgress=True)

	# disconnect paint weights
	_disconnectPaintWeights(rbsNode)

	srcAttr = '%s.it[%d].%s' % (rbsNode, srcIdx, _wAttr)
	destAttr = '%s.it[%d].%s' % (rbsNode, destIdx, _wAttr)
	pAttr = '%s.weightList[0].weights' % rbsNode

	# copy weights from source to paint
	cmds.connectAttr(srcAttr, pAttr, f=True)
	cmds.getAttr(pAttr, mi=True)
	cmds.disconnectAttr(srcAttr, pAttr)

	# connect paint to destination weights
	cmds.connectAttr(pAttr, destAttr, f=True)

	affectedWeightList = cmds.percent(rbsNode, affectedVtxList, q=True, v=True)

	# set weights
	cmds.progressBar('mainProgressBar', e=True, beginProgress=True, isInterruptable=False, status='Setting weights...', maxValue=vtxCount)
	for i, vtx in enumerate(affectedVtxList):
		cmds.progressBar('mainProgressBar', e=True, step=1)
		cmds.percent(rbsNode, vtx, v=affectedWeightList[symmMap[i]])
	cmds.progressBar('mainProgressBar', e=True, endProgress=True)

	# show the paint tool
	cmds.select(obj)
	cmds.setToolTo(cmds.artAttrCtx(oaa='%s.%s.weights' % (_rbsNodeName, rbsNode)))
コード例 #8
0
ファイル: softcluster.py プロジェクト: MaxIsJames/max-scripts
def paint_tool():
    if cmds.artAttrCtx('artAttrCtx1', q=True, ex=True) is not True:
        cmds.artAttrCtx('artAttrCtx1')
    cmds.setToolTo('artAttrCtx1')