Website Youtube GitHub

mGear Framework Forum

Load more than one skin via the shifter guide settings?

Is there a way to load more than one skin via the shifter guide settings?
I thought it would load all files it can find in that folder.

I suggest not to use this. Uncheck import skin, and use a post script instead.

Here is an example I posted. Most of the code is just to set up my directory structure.

The key command is

from mgear.core import skin
skinpath = "your/path/to/the/file/yourfile.jSkinPack"
skin.importSkinPack(skinpath)

Thanks Chris but i have no clue how to use this info. Im a totally scripting novice.

You can use the menu to load a skinpack file.

Otherwise, I think the custom steps PRE and POST are covered in this video. https://www.youtube.com/watch?v=gz2zCcqgJdo&list=PL9LaIDCCDjfimQVcMdh0rG0MPabPG9FK-&index=13&t=0s

Relatively short version.

  1. SETUP: In your Maya.env file you have to specify a directory where you will store your custom step scripts.
    my example. It does not have to be named “build”. It can be whatever you want:
    MGEAR_SHIFTER_CUSTOMSTEP_PATH = /Users/chrislesage/production/mgear/build
  2. In the guide settings window you have open in your screenshot, click on the “Custom Steps” tab.
  3. At the bottom half, you’ll find POST scripts. These are scripts that run after your rig is built.
  4. Click “New”. It will let you save a new Python script. It will save it in that directory you specified in MGEAR_SHIFTER_CUSTOMSTEP_PATH.
  5. Open the Python script in a text editor.
  6. In that Python script underneath the line
    def run(self, stepDict):
    you can put your code. Make sure to change the path to your path to your jSkin file. Or gSkin, depending on what you exported.
from mgear.core import skin
skinpath = "your/path/to/the/file/yourfile.jSkinPack"
skin.importSkinPack(skinpath)

When you build the rig, it will run that code, and load your skinning.

6 Likes

Many thanks that does help a lot. I will report if i get it working.

Cheers.

Somehow i messed it up.

I get this error message.

The step:V:/Data/Tools/mgear2020/build/mgearman.py has failed. Continue with next step?

An exception of type IndentationError occured.

Traceback (most recent call last):
File “V:\Data\Tools\mgear2020\scripts\mgear\shifter\guide.py”, line 1158, in runStep
customStep = imp.load_source(fileName, runPath)
File “V:/Data/Tools/mgear2020/build/mgearman.py”, line 12
from mgear.core import skin
^
IndentationError: expected an indented block

Here is the code i pasted into the mgearman.py

import mgear.shifter.custom_step as cstp


class CustomShifterStep(cstp.customShifterMainStep):
    def __init__(self):
        self.name = "mgearman"


    def run(self, stepDict):
    
    from mgear.core import skin
     skinpath = V:\Data\2020\maya_projects\mGearman\skin\mgearman_skin.gSkinPack
     skin.importSkinPack(skinpath)
    
        """Run method.

            i.e:  stepDict["mgearRun"].global_ctl  gets the global_ctl from
                    shifter rig build bas
            i.e:  stepDict["mgearRun"].components["control_C0"].ctl  gets the
                    ctl from shifter component called control_C0
            i.e:  stepDict["otherCustomStepName"].ctlMesh  gets the ctlMesh
                    from a previous custom step called "otherCustomStepName"
        Arguments:
            stepDict (dict): Dictionary containing the objects from
                the previous steps

        Returns:
            None: None
        """
        return

I highly recommend learning the basics of Python if you intend to continue using scripts. Chris Zurbrigg has some good Maya Python intro videos.

Ordinarily I would answer by telling you how to read the error message so you could fix it yourself and better understand future errors. But you have a few issues:

  1. Indentation is important in Python. Code inside functions or blocks of code must be indented with tabs or spaces. Look at the example in the other thread I posted. Look at how the lines of code are aligned with each other. That’s why you have an IndentationError.
  2. Your skinpath is what‘s called a string in Python. A string means a line of text. It must be inside quotation marks. "V:/Data/202/etc/etc/" You removed the quotation marks from my example code.
  3. Also, in Python a \ backslash will not work inside a string because it is used as a special character. So you’ll either have to use "V:\\Data\\2020\\" or "V:/Data/2020/" or r"V:\Data\2020\" with an r in the front to tell it to ignore the backslashes.

One other thing that might make it a bit simpler. When you add a script in Custom Steps, it adds a lot of boilerplate code. All the stuff like class CustomShifterStep() and def run(self, step, Dict) ETC. ETC… You need that stuff for more complex scripts.

But you don’t need it for your simple script here.

You can delete all the lines of code in that entire script, and just paste the 3 lines into the file.

Many thanks i do an other take tomorrow.

I tried to learn python several times. But every time i loose interest. I need it maybe once a year.

Pasting only the three lines of code did work.
I tried to get it working with the rest of the code but i got the same error over and over.

But now its working with the three lines.
Thanks.