Maya blendshape (MEL question)...

Maya blendshape (MEL question)...

Anonymous
Not applicable
531 Views
1 Reply
Message 1 of 2

Maya blendshape (MEL question)...

Anonymous
Not applicable

Hello, I am new to mel scripting, so please bear with me. I am trying to transfer my blendshapes from my Daz3d rig to my custom one.
I am duplicating them one by one, but I have multiple characters, so I am trying to make a script to do it for me.

so far this is what I got:

select -r -sym GenesisFBXASC046Shape ;
setAttr "GenesisFBXASC046V4_PHMEyeOpenFBXASC045CloseR_head.Genesis_V4_PHMEyeOpen_CloseR_head" 1;
duplicate -rr;
// Result: GenesisFBXASC046Shape1 //
setAttr "GenesisFBXASC046V4_PHMEyeOpenFBXASC045CloseR_head.Genesis_V4_PHMEyeOpen_CloseR_head" 0;

I have 50 blendshapes so far for each character, what would be the best course of action for this scripted?

Thank you for your time.

0 Likes
532 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

If you want to make the script work for all blendShape then you can use the following MEL procedure. It is a generic procedure.

 

proc blendShapeSetAttribute(int $blendShapeCount, string $shapeName, string $attrName)

{

    string $shape = $shapeName;

    string $attr = $shapeName + $attrName;

    for ($count=1; $count<$blendShapeCount; $count++)

    {

            if ($count != 0)

            {

                $shape = $shapeName + $count;

                $attr  = $shape + "."+ $attrName;

            }

                       

          select -r -sym $shape;

          setAttr $attr 1;

          duplicate -rr;

          setAttr $attr 0;

 

    }  

};

 

The above procedure will work for any blendShape or any polygons.  I have executed the above procedure like below for “pSphere”.

blendShapeSetAttribute(50, "pSphere", "scaleX");

for “pSphere1” to “pSphere49” it will select the current sphere and set the given attribute “scaleX” to 1.

 

In your case, if attribute name is same irrespective of shape count and shapeName starts with 0 instead of 1, then use the below procedure.

proc blendShapeSetAttribute(int $blendShapeCount, string $shapeName, string $attrName)

{

    string $shape = $shapeName;

    for ($count=0; $count<$blendShapeCount; $count++)

    {

            if ($count != 0)

            {

                $shape = $shapeName + $count;

            }

                       

          select -r -sym $shape;

          setAttr $attr 1;

          duplicate -rr;

          setAttr $attr 0;

 

    }  

};

 

Call the procedure like below.

blendShapeSetAttribute(50, "GenesisFBXASC046Shape", "GenesisFBXASC046V4_PHMEyeOpenFBXASC045CloseR_head.Genesis_V4_PHMEyeOpen_CloseR_head");

0 Likes