# Maya 2013 Rigging simple script Help

 11 November 2012 BrioBriss PRO   portfolio Olivier Brisson 3D animation Cégep du Vieux Montréal Montreal, Canada Maya 2013 Rigging simple script Help Alright, here's the issue. I actually have a script on some bones of the legs/arms of my character to make the leg/arm stretch. It works with a measure tool, so as far as the distance tool is higher than the base value (when the character is at his initial pose), the arms/legs will stretch. The problem is that when I scale the Master Icon of my character, it scale the distances tools too, so make the character arms and legs stretch, but I don't want it. I want that the arms and legs don't stretch when I scale the whole character with the Master Icon. So yeah, all I want is to be able to scale the whole character with the Master Icon without the legs and arms stretch. (Don't know if it's clear here?) Here's the initial script for one bone of the left leg: 1- if ( RG_L_legStretchDistanceDimension_Shape1.distance > 7 ) { BD_L_leg_1.scaleZ = (RG_L_legStretchDistanceDimension_Shape1.distance/7); } else { BD_L_leg_1.scaleZ = 1; } 7 is the Distance value of the distance tool. And here's the script attempt (that don't works actually) to add (multiply) the Master Icon stretch value to the distance tool value. This way it's supposed to cancel the extra stretch when I scale the Master Icon. I used to try with only the Scale X of the Master Icon and it "worked", only, when I scaled the Master Icon in Y or Z, it didn't worked. So I attempted to connect all the 3 axis separately, but it don't works. I guess it's just the way to write the script, telling I want it to multiply the Distance Tool value (7) with the X, Y or Z of the Master Icon (or only X and Z or only Y and X etc etc). Here's the script attempt: 2- if ( RG_L_legStretchDistanceDimension_Shape1.distance > 7*(RG_C_masterIcon_1.scaleX || RG_C_masterIcon_1.scaleY || RG_C_masterIcon_1.scaleZ)) { BD_L_leg_1.scaleZ = (RG_L_legStretchDistanceDimension_Shape1.distance/7*(RG_C_masterIcon_1.scaleX || RG_C_masterIcon_1.scaleY || RG_C_masterIcon_1.scaleZ) ); } else { BD_L_leg_1.scaleZ = 1; } Here's some picture to show what happen (Maybe it'll help to understand the problem) 1. Initial pose: 2. Normal leg stretch (without scaling the Master Icon): 3. And now the problem it goes when I scale the Master Icon (the legs aren't stretched voluntarily they are at their initial pose (like on the 1st pic, only the Master Icon got scaled)) - What I want is that the pose stay like on the 1st pic when I scale the Master Icon. __________________ Portfolio | Videos share quote
 11 November 2012 Lomax Expert   portfolio Jared Lindquist Technical Animator Limited Slip Studio Orlando, USA What you need is a secondary measurement to act as a reference point for the default length. This could either be a second set of measurement nodes; or perhaps a linear curve made from the joints, passed through a curveInfo node. The resulting distance/arcLength value would be used instead of an absolute length in the stretch calculations. __________________ share quote
 11 November 2012 BrioBriss PRO   portfolio Olivier Brisson 3D animation Cégep du Vieux Montréal Montreal, Canada Originally Posted by Lomax: What you need is a secondary measurement to act as a reference point for the default length. This could either be a second set of measurement nodes; or perhaps a linear curve made from the joints, passed through a curveInfo node. The resulting distance/arcLength value would be used instead of an absolute length in the stretch calculations. Yeah I can understand what you mean here, gives me other ideas, but at best I'd like to only have the script language to say: "Leg Scale = Leg Distance tool * (Marster Icon Scale X "or" Marster Icon Scale Y "or" Marster Icon Scale Z "or" both of Master Icon Scale (ex: X+Y) "or" All of them) Don't know if it's clear here? Actually it's the "or" that I don't know how to write it and how to say it can be all of Master Icon Scales or just 2 of it or just one. __________________ Portfolio | Videos Last edited by BrioBriss : 11 November 2012 at 07:42 PM. share quote
 11 November 2012 ogbonna Veteran portfolio Nathaniel Anozie Baltimore, USA Hi, A couple of ideas that may be helpful for globaling scaling rig. Have one global scale attribute (so could use connection editor and get scaleY connected to scaleX and scaleZ, and could rename scaleY using aliasAttr MEL command). Change math formula so when master control's global scale changes the distance measure tool calculation gets divided by this number. So say global scale was 2. Then distance measure is 2*defaultDistance (assuming measure locators are under the hierarchy of the global control). So dividing it by the global scale the distance measure would be (2*defaultDistance/2 = defaultDistance). And the scale for the joint can be something like currentDistance/defaultDistance after the correction. In summary something like: joint1.scaleX = (currentDistance/ (defaultDistance/control.globalScale) ) I may have made some mistakes in this, but hope it is helpful. Cheers, Nate Inspired by Jason Schleifer's Animator Friendly Rigging (jasonschleifer dot com) share quote
 11 November 2012 BrioBriss PRO   portfolio Olivier Brisson 3D animation Cégep du Vieux Montréal Montreal, Canada Thanks for the help, Ogbonna, I'll check that out. Actually someone posted pretty much what I want on another topic about my case, only he didn't posted the code lines I need, maybe some people can know which kind of code lines I can add to make it work. Here's his post: The || operator will always return 1 or 0. So the result of 7*(RG_C_masterIcon_1.scaleX || RG_C_masterIcon_1.scaleY || RG_C_masterIcon_1.scaleZ) will either be 7 or 0, and that is not what you want. Your approach is correct though. So you just need to add a few lines to get the multiplier calculated correctly. Do you really need to allow for non-proportional scale? I don't know that much in script so if people can help here it'll help me a lot! Thanks __________________ Portfolio | Videos share quote
 11 November 2012 CGTalk Moderation Expert Thread automatically closed This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum. __________________ CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.