Home Website Youtube GitHub

Import skin failed

Hi,
I can’t seem to get mgear to import a skin pack.

I’m trying to import the skin pack through a post custom step script. I get this type of warning for each skinned object when the post script tries to run:

# Warning: Object: Short_sim_shirt Skiped. Can't found corresponding deformer for the following joints:

followed by a list of joints. I don’t know what I’m doing wrong.

the post script looks like this:

import mgear.shifter.custom_step as cstp


class CustomShifterStep(cstp.customShifterMainStep):
    """Custom Step description
    """

    def setup(self):
        """
        Setting the name property makes the custom step accessible
        in later steps.

        i.e: Running  self.custom_step("importSkins")  from steps ran after
             this one, will grant this step.
        """
        self.name = "importSkins"

    def run(self):
        """Run method.

            i.e:  self.mgear_run.global_ctl
                gets the global_ctl from shifter rig build base

            i.e:  self.component("control_C0").ctl
                gets the ctl from shifter component called control_C0

            i.e:  self.custom_step("otherCustomStepName").ctlMesh
                gets the ctlMesh from a previous custom step called
                "otherCustomStepName"

        Returns:
            None: None
        """
        from mgear.core import skin
        skinpath = "N:\Football\Promo\Maya\Assets\data\mGear\Skins\Sim_kit\SimKitPack.gSkinPack"
        skin.importSkinPack(skinpath)

        return

Any suggestions on how to get this working is greatly appreciated.
Matt

make all slashes in your skinpath double slashes.
in python a back slash is the main escape character. So to actually use a blackslash in a string you need \.

1 Like

Even in a string?

I’m happily using back slashes in strings in other python scripts without issue.

Ok, I think I’ve found the problem.
It’s the fact that the joints that I’m saving the skinning out for are all in a namespace.
I’ve written a little script to temporarily remove the joints from the name space so I can import the skinning, then put them back into the namespace.

oh yes, if the skin file lists joints that are missing or misspelled in any way, including namespace, even if it’s just one joint - it won’t load. Super annoying!

What’s everyone’s work around to that? I still haven’t found one that’s easy and quick.

1 Like

Ok I have it working now!
Stripping off the name space from all the joints solved it.
This is my some what ham fisted post custom step script:

import mgear.shifter.custom_step as cstp
import maya.cmds as cmds


class CustomShifterStep(cstp.customShifterMainStep):


    def setup(self):
        
        self.name = "importSkins"

    def run(self):
        mySel = cmds.select('DHIbody:*', r=True)
        newSet = cmds.sets()
        cmds.select(clear=True)
        cmds.namespace( removeNamespace = ":DHIbody", mergeNamespaceWithRoot = True)
        
        from mgear.core import skin
        skinpath = "N:\Football\Promo\Maya\Assets\data\mGear\Skins\Sim_kit\SimKitPack.gSkinPack"
        skin.importSkinPack(skinpath)                 
        
        cmds.select(clear=True)
        members = cmds.sets( newSet, q=True )
        cmds.namespace( add='DHIbody' )
        for myObj in members:
            cmds.rename(myObj,'DHIbody:%s' %myObj)
            
        cmds.delete(newSet)

        return
2 Likes

That’s a good point. I just made this feature request for times when you have a typo on a joint that isn’t even being used. More flexibility / adaptability when importing weights

The only real workaround right now is to go into the jSkin file and edit it. This is why I always use jSkin ascii instead of gSkin binary.

Or if you exported the skin with a typo in your bone, temporarily rename joints wrong so they match the file, import, then name them back, and then export again.

1 Like

Possibly just by luck, especially since you seem to use uppercase in directory names.

If you include any letter like \n or \r or \t or several others, you’ll end up with malformed paths. 2. Lexical analysis — Python 3.11.2 documentation

You can use r"\my\path" to make it a raw string, or "\\my\\path" or "/my/path" to avoid parsing string literals. Or better yet, the os.path library.

1 Like