Created
October 29, 2021 14:44
-
-
Save tokejepsen/ad9906e54381aad53828cd3d1e1707e2 to your computer and use it in GitHub Desktop.
Maya: Batch Transfer Ngskintools Weights
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Select targets then source last. | |
""" | |
import pymel.core as pc | |
from ngSkinTools.mllInterface import MllInterface | |
selection = pc.ls(selection=True) | |
targets = selection[:-1] | |
source = selection[-1] | |
skin_cluster = source.getShape().listConnections(type="skinCluster")[0] | |
joints = skin_cluster.listConnections(type="joint") | |
source_mll = MllInterface() | |
source_mll.setCurrentMesh(str(source)) | |
id_by_path = {} | |
for info in source_mll.listInfluenceInfo(): | |
id_by_path[info.path] = info.logicalIndex | |
for target in targets: | |
args = joints + [target] | |
pc.skinCluster(*args) | |
influences_mapping = {} | |
target_mll = MllInterface() | |
target_mll.setCurrentMesh(str(target)) | |
target_mll.initLayers() | |
for info in target_mll.listInfluenceInfo(): | |
source_id = id_by_path[info.path] | |
influences_mapping[source_id] = info.logicalIndex | |
source_mll.transferWeights(str(target), influences_mapping, vertexTransferMode="closestPoint") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment