Created
May 10, 2019 09:33
-
-
Save tokejepsen/36286523b8f3e70fec9889d131f21856 to your computer and use it in GitHub Desktop.
mGear Post Script DeltaMush Import
This file contains 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
import os | |
import pymel.core | |
basename = os.path.basename(pymel.core.sceneName()) | |
filename = os.path.splitext(basename)[0] | |
directory = os.path.dirname(pymel.core.sceneName()) | |
# Find *.deltamush folder starting with same name as current file | |
json_files = [] | |
for folder in os.listdir(directory): | |
if folder == (filename + ".deltamush"): | |
path = os.path.join(directory, folder) | |
for f in os.listdir(path): | |
if f.endswith(".json"): | |
json_files.append(os.path.join(path, f)) | |
for json_file in json_files: | |
mesh_name = os.path.splitext(os.path.basename(json_file))[0] | |
if not pymel.core.objExists(mesh_name): | |
raise ValueError( | |
"Missing \"{0}\" for delta mush from \"{1}\"".format( | |
mesh_name, json_file | |
) | |
) | |
delta_mush = pymel.core.deltaMush(mesh_name) | |
pymel.core.deformerWeights( | |
os.path.basename(json_file), | |
path=os.path.dirname(json_file), | |
im=True, | |
deformer=delta_mush, | |
method="index" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment