Rigging

Rigging101 » Rigging128

Stretch complex ( code source ) (1 post)

About This Topic

Tags

No tags yet.

  1. vitorlobo

    offline
    Member
    Posted 6 years ago
    #

    Hi guys!
    This is my first post in the forum!

    Recently I developed a Python script for the stretch effect.However, it is still very simple and I intend to do something more complex.

    For example, an attribute of stretch in the controller "polevector" so that it can stretch the shouder + elbow of one arm translate.Z axis while the axis scale.X

    THe source code for the simple effect of stretch. In this case, it applies to arms, is stretching the shaft scale.X in the case of legs, to change the scale.X scale.Y

    import maya.cmds as cmds

    def makeSS():

    sel = cmds.ls(sl=True)
    if sel != 3:
    'You need select only two joints + the controler of ikHandle '

    StartJoint = cmds.createNode('transform',n=sel[0]+'_point1')
    EndJoint = cmds.createNode('transform',n=sel[2]+'_point2')

    cmds.delete( cmds.parentConstraint(sel[0],StartJoint))
    cmds.delete( cmds.parentConstraint(sel[2],EndJoint))

    # select joint 1 and ikHandle
    cmds.pointConstraint(sel[0],StartJoint)
    cmds.pointConstraint(sel[2],EndJoint)

    # Make DistanceBetween , Condition and MultiplyDivide nodes
    Dist = cmds.shadingNode('distanceBetween', asUtility=1, name=sel[0]+'_Dist')
    Cond = cmds.shadingNode('condition', asUtility=1,name=sel[0]+'_Cond')
    Div = cmds.shadingNode('multiplyDivide', asUtility=1, name=sel[0]+'_Divide')

    # Connect point1 and point 2 in DistanceBetween pointsAxis
    cmds.connectAttr(StartJoint+'.translate', Dist+'.point1',f=True)
    cmds.connectAttr(EndJoint+'.translate', Dist+'.point2',f=True)

    cmds.connectAttr(Dist+'.distance', Cond+'.firstTerm', f=True)
    cmds.connectAttr(Dist+'.distance', Div+'.input1X', f=True)
    defvalue = cmds.getAttr(Dist+'.distance')
    cmds.connectAttr(Div+'.outputX', Cond+'.colorIfTrueR', f=True)
    cmds.setAttr(Cond+'.secondTerm', defvalue+1)
    cmds.setAttr(Div+'.input2X',defvalue+1)
    cmds.setAttr(Cond+'.operation',3)
    cmds.setAttr(Div+'.operation', 2)

    cmds.connectAttr(Cond+'.outColorR', sel[0]+'.scaleX', f=True)
    cmds.connectAttr(Cond+'.outColorR', sel[1]+'.scaleX',f=True)

    makeSS()

    I want to do this effect:
    http://img833.imageshack.us/img833/3764/55578581.jpg

    Any idea?

Reply

You must log in to post.

Rigging101 » Rigging128
1,099 posts in 307 topics over 110 months by 188 of 8,226 members. Latest: fashionpvp, d2q4p5z2j, gasheldonl