Website Youtube GitHub

Faster way to import multiple Skin Packs


#1

Hello. Does anyone know if there is a faster way to import all your skin pack instead of doing it one by one? Is it possible to script this?


#2

Hi Chantelle,

Yes of course. Everything can be scripted. :slight_smile:

Here is the shortest example possible, and then the actual script I use. But the actual script I use depends on the network path that I designed. I keep all of my build scripts and data files in a per-character folder, and then find that folder by querying the character name from the guide.

Short example:

from mgear.core import skin

skinPath = r"P:\my\production\drive\characters\billy\billySkin.jSkinPack"
skin.importSkinPack(skinpath)

My production example
Note: In os.path, you can use .. in the path to go UP a directory. So I climb up to my root rigging directory

import os
import sys
import pymel.core as pm
import mgear.shifter.custom_step as cstp
from mgear.core import skin


class CustomShifterStep(cstp.customShifterMainStep):
    def __init__(self):
        self.name = "import_skinning"
        self.charName = pm.PyNode('guide').rig_name.get()


    def run(self, stepDict):
        char = self.charName
        # Start by getting the path of this script that is running.
        postpath = os.path.abspath(os.path.dirname(__file__))
        # Then climb up to my root rigging directory
        basepath = os.path.abspath(os.path.join(postpath, '../../../..'))
        dataPath = 'data'
        # Here join will make a template that looks like basepath + dataPath + etc.
        # EXAMPLE: 'P:\production\rigging\data\characters\billy\skinning\skin.jSkinPack'
        skinpath = os.path.abspath(os.path.join(basepath, dataPath, 'characters', char, 'skinning', 'skin.jSkinPack'))
        
        if os.path.isfile(skinpath):
            skin.importSkinPack(skinpath)
        else:
            return False
        
        return


#3

Ah that’s fantastic! This is a big help! Thank you very much!