def polyDeformerWeights(*args, **kwargs): """Copies the weights from one deformer to another. Parameters ---------- *args : str List of equal number of meshes and deformers. If empty, the active selection is used. Raises ------ RuntimeError If the selected deformers do not deform the selected meshes, or if the selected meshes do not have poly symmetry data computed. """ selectedMeshes = _getSelectedMeshes(*args) selectedDeformers = _getSelectedDeformers(*args) if not selectedMeshes or not selectedDeformers: raise polySymmetry.utils.InvalidSelection( "Must select at least one mesh and one deformer.") return if len(selectedMeshes) != len(selectedDeformers): raise polySymmetry.utils.InvalidSelection( "Must select exactly one deformer per mesh.") return logMsg = "Result: {} weights on {} ({})." actionName = 'Flipped' if 'flip' in kwargs else 'Mirrored' with undoChunk(): for mesh, deformer in zip(selectedMeshes, selectedDeformers): cmds.polyDeformerWeights(sourceMesh=mesh, sourceDeformer=deformer, destinationMesh=mesh, destinationDeformer=deformer, **kwargs) _INFO(logMsg.format(actionName, mesh, deformer))
def copyPolyDeformerWeights(*args): """Copies the weights from one deformer to another. Parameters ---------- *args : str List of one or two meshes, and two deformers. If empty, the active selection is used. Raises ------ RuntimeError If the selected deformers do not deform the selected mesh(es), or if the selected mesh(es) do not have poly symmetry data computed. """ selectedMeshes = _getSelectedMeshes(*args) selectedDeformers = _getSelectedDeformers(*args) if len(selectedMeshes) not in (1, 2) or len(selectedDeformers) != 2: _ERR("Must select a source mesh, a destination mesh (optional), " "a source deformer, and a destination deformer.") return kwargs = { 'sourceMesh': selectedMeshes[0], 'sourceDeformer': selectedDeformers[0], 'destinationMesh': selectedMeshes[-1], 'destinationDeformer': selectedDeformers[1], 'direction': 1 } cmds.polyDeformerWeights(**kwargs) _INFO("Result: Copied weights from {sourceDeformer} ({sourceMesh}) " "to {destinationDeformer} ({destinationMesh})".format(**kwargs))