zoukankan      html  css  js  c++  java
  • 09 IKFKMatch.txt

    //advanced skeleton 3.5 update.
    //test in maya 2011.
    //this script is free.
    //adding match IK Fk feature for advanced skleton 3.5
    //writen by davood tabatabaei iran-mashhad-parshonar company.
    //email: davood.taba@gmail.com
    //how to use:
    //open scrip in script editor and select all texts and drag into shelf . optional: use match icon if you like.
    // completely create your rig then run script and then click on "adding match feature to rig"(in main rig not referenced rig). now you are able to match ik to fk or reverse on hands and legs.
    //important: do not rename any part of advanced skelete.
    //if you referenced rig into other file it must be after adding match feature this means you must frist add match feature then reference it.
    window -width 150 -t "IK FK Match Tool For Adv Skeleton By Davood Tabatabaei";
    columnLayout -adjustableColumn true;
    textField -tx "Enter Character's NameSpace Else Remove This text" t1;
    button -label "Adding Match feature To Rig" -command "Add" addmatch;
    string $ex = ("*" + ":" + "PoleExtraArm_L1");
    if (`objExists $ex`){
    button -edit -en 0 -l "you have add Match feature already" addmatch;
    };
    string $ex = ("*" + "PoleExtraArm_L1");
    if (`objExists $ex`){
    button -edit -en 0 -l "you have add Match feature already" addmatch;
    };
    button -label "Convert Left Hand to IK" -command "LHtoIK";
    button -label "Convert Left Hand to FK" -command "LHtoFK";
    button -label "Convert Right Hand to IK" -command "RHtoIK";
    button -label "Convert Right Hand to FK" -command "RHtoFK";
    button -label "Convert Left Foot to IK" -command "LFtoIK";
    button -label "Convert Left Foot to FK" -command "LFtoFK";
    button -label "Convert Right Foot to IK" -command "RFtoIK";
    button -label "Convert Right Foot to FK" -command "RFtoFK";
    showWindow;
    proc LFtoIK()
    {
    string $ns = `textField -q -tx t1 `;
    $pos = `xform -q -ws -t ($ns + "IKLeg_L1")`;
    move -rpr -ws $pos[0] $pos[1] $pos[2] ($ns + "IKLeg_L");
    $rot = `xform -q -ws -ro ($ns +"IKLeg_L1")`;
    rotate -a -ws $rot[0] $rot[1] $rot[2] ($ns + "IKLeg_L");
    $posIK = `xform -q -ws -t ($ns + "PoleLeg_L1")`;
    move -rpr -ws $posIK[0] $posIK[1] $posIK[2] ($ns + "PoleLeg_L");
    setAttr ($ns + "FKIKLeg_L.FKIKBlend") 10;
    };
    proc LFtoFK()
    {
    string $ns = `textField -q -tx t1 `;
    select -r ($ns +"IKXHip_L") ;
    select -tgl ($ns +"FKHip_L") ;
    doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
    parentConstraint -weight 1;
    // Result: FKHip_L_parentConstraint1 //
    // Result: FKHip_L_parentConstraint1
    select -r ($ns +"FKHip_L_parentConstraint1") ;
    delete;
    select -r ($ns +"IKXKnee_L") ;
    select -tgl ($ns +"FKKnee_L") ;
    doCreateParentConstraintArgList 1 { "0","1","1","1","1","1","0","1","","1"};
    // Result: FKKnee_L_parentConstraint1 //
    select -r ($ns +"FKKnee_L_parentConstraint1") ;
    delete;
    select -r ($ns +"IKXAnkle_L") ;
    select -tgl ($ns +"FKAnkle_L") ;
    doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
    parentConstraint -weight 1;
    select -r ($ns +"FKAnkle_L_parentConstraint1") ;
    doDelete;
    setAttr ($ns+"FKIKLeg_L.FKIKBlend") 0;
    };
    proc RFtoIK()
    {
    string $ns = `textField -q -tx t1 `;
    $pos = `xform -q -ws -t ($ns + "IKLeg_R1")`;
    move -rpr -ws $pos[0] $pos[1] $pos[2] ($ns + "IKLeg_R");
    $rot = `xform -q -ws -ro ($ns +"IKLeg_R1")`;
    rotate -a -ws $rot[0] $rot[1] $rot[2] ($ns + "IKLeg_R");
    $posIK = `xform -q -ws -t ($ns + "PoleLeg_R1")`;
    move -rpr -ws $posIK[0] $posIK[1] $posIK[2] ($ns + "PoleLeg_R");
    setAttr ($ns + "FKIKLeg_R.FKIKBlend") 10;
    };
    proc RFtoFK()
    {
    string $ns = `textField -q -tx t1 `;
    select -r ($ns +"IKXHip_R") ;
    select -tgl ($ns +"FKHip_R") ;
    doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
    parentConstraint -weight 1;
    // Result: FKHip_R_parentConstraint1 //
    // Result: FKHip_R_parentConstraint1
    select -r ($ns +"FKHip_R_parentConstraint1") ;
    delete;
    select -r ($ns +"IKXKnee_R") ;
    select -tgl ($ns +"FKKnee_R") ;
    doCreateParentConstraintArgList 1 { "0","1","1","1","1","1","0","1","","1"};
    // Result: FKKnee_R_parentConstraint1 //
    select -r ($ns +"FKKnee_R_parentConstraint1") ;
    delete;
    select -r ($ns +"IKXAnkle_R") ;
    select -tgl ($ns +"FKAnkle_R") ;
    doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
    parentConstraint -weight 1;
    select -r ($ns +"FKAnkle_R_parentConstraint1") ;
    doDelete;
    setAttr ($ns+"FKIKLeg_R.FKIKBlend") 0;
    };
    proc LHtoIK()
    {
    string $ns = `textField -q -tx t1 `;
    $pos = `xform -q -ws -t ($ns + "IKArm_L1")`;
    move -rpr -ws $pos[0] $pos[1] $pos[2] ($ns + "IKArm_L");
    $rot = `xform -q -ws -ro ($ns +"IKArm_L1")`;
    rotate -a -ws $rot[0] $rot[1] $rot[2] ($ns + "IKArm_L");
    $posIK = `xform -q -ws -t ($ns + "PoleArm_L1")`;
    move -rpr -ws $posIK[0] $posIK[1] $posIK[2] ($ns + "PoleArm_L");
    setAttr ($ns + "FKIKArm_L.FKIKBlend") 10;
    };
    proc LHtoFK()
    {
    string $ns = `textField -q -tx t1 `;
    select -r ($ns +"IKXShoulder_L") ;
    select -tgl ($ns +"FKShoulder_L") ;
    doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
    parentConstraint -weight 1;
    // Result: FKShoulder_L_parentConstraint1 //
    // Result: FKShoulder_L_parentConstraint1
    select -r ($ns +"FKShoulder_L_parentConstraint1") ;
    delete;
    select -r ($ns +"IKXElbow_L") ;
    select -tgl ($ns +"FKElbow_L") ;
    doCreateParentConstraintArgList 1 { "0","1","1","1","1","0","1","1","","1" };
    // Result: FKElbow_L_parentConstraint1 //
    select -r ($ns +"FKElbow_L_parentConstraint1") ;
    delete;
    select -r ($ns +"IKXWrist_L") ;
    select -tgl ($ns +"FKWrist_L") ;
    doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
    parentConstraint -weight 1;
    select -r ($ns +"FKWrist_L_parentConstraint1") ;
    doDelete;
    setAttr ($ns+"FKIKArm_L.FKIKBlend") 0;
    };
    proc RHtoIK()
    {
    string $ns = `textField -q -tx t1 `;
    $pos = `xform -q -ws -t ($ns + "IKArm_R1")`;
    move -rpr -ws $pos[0] $pos[1] $pos[2] ($ns + "IKArm_R");
    $rot = `xform -q -ws -ro ($ns +"IKArm_R1")`;
    rotate -a -ws $rot[0] $rot[1] $rot[2] ($ns + "IKArm_R");
    $posIK = `xform -q -ws -t ($ns + "PoleArm_R1")`;
    move -rpr -ws $posIK[0] $posIK[1] $posIK[2] ($ns + "PoleArm_R");
    setAttr ($ns + "FKIKArm_R.FKIKBlend") 10;
    };
    proc RHtoFK()
    {
    string $ns = `textField -q -tx t1 `;
    select -r ($ns +"IKXShoulder_R") ;
    select -tgl ($ns +"FKShoulder_R") ;
    doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
    parentConstraint -weight 1;
    // Result: FKShoulder_R_parentConstraint1 //
    // Result: FKShoulder_R_parentConstraint1
    select -r ($ns +"FKShoulder_R_parentConstraint1") ;
    delete;
    select -r ($ns +"IKXElbow_R") ;
    select -tgl ($ns +"FKElbow_R") ;
    doCreateParentConstraintArgList 1 { "0","1","1","1","1","0","1","1","","1" };
    // Result: FKElbow_R_parentConstraint1 //
    select -r ($ns +"FKElbow_R_parentConstraint1") ;
    delete;
    select -r ($ns +"IKXWrist_R") ;
    select -tgl ($ns +"FKWrist_R") ;
    doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
    parentConstraint -weight 1;
    select -r ($ns +"FKWrist_R_parentConstraint1") ;
    doDelete;
    setAttr ($ns+"FKIKArm_R.FKIKBlend") 0;
    };
    proc Add()
    {
    string $ns = `textField -q -tx t1 `;
    select -r PoleExtraArm_L ;
    duplicate -rr;
    // Result: PoleExtraArm_L1 //
    select -r PoleExtraArm_L1|PoleArm_L|PoleAnnotateTargetArm_L ;
    delete;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintArm_L|PoleExtraArm_L1|PoleArm_L.rotateX;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintArm_L|PoleExtraArm_L1|PoleArm_L.rotateY;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintArm_L|PoleExtraArm_L1|PoleArm_L.rotateZ;
    setAttr -lock false "PoleExtraArm_L1|PoleArm_L.rx";
    setAttr -lock false "PoleExtraArm_L1|PoleArm_L.ry";
    setAttr -lock false "PoleExtraArm_L1|PoleArm_L.rz";
    select -r FKXElbow_L ;
    select -r PoleExtraArm_L1|PoleArm_L ;
    rename "PoleExtraArm_L1|PoleArm_L" "PoleArm_L1";
    // Result: PoleArm_L1 //
    select -r FKXElbow_L ;
    select -add PoleArm_L1 ;
    doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
    parentConstraint -mo -weight 1;
    // Result: PoleArm_L1_parentConstraint1 //
    select -r IKArm_L ;
    duplicate -rr;
    // Result: IKArm_L1 //
    select -r IKArm_L1|IKXArmHandle_L ;
    delete;
    select -r Wrist_L ;
    select -add IKArm_L1 ;
    doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
    parentConstraint -mo -weight 1;
    // Result: IKArm_L1_parentConstraint1 //
    setAttr -lock true "FKElbow_L.rx";
    setAttr -lock true "FKElbow_L.rz";
    select -r PoleExtraArm_R ;
    duplicate -rr;
    // Result: PoleExtraArm_R1 //
    select -r PoleExtraArm_R1|PoleArm_R|PoleAnnotateTargetArm_R ;
    delete;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintArm_R|PoleExtraArm_R1|PoleArm_R.rotateX;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintArm_R|PoleExtraArm_R1|PoleArm_R.rotateY;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintArm_R|PoleExtraArm_R1|PoleArm_R.rotateZ;
    setAttr -lock false "PoleExtraArm_R1|PoleArm_R.rx";
    setAttr -lock false "PoleExtraArm_R1|PoleArm_R.ry";
    setAttr -lock false "PoleExtraArm_R1|PoleArm_R.rz";
    select -r FKXElbow_R ;
    select -r PoleExtraArm_R1|PoleArm_R ;
    rename "PoleExtraArm_R1|PoleArm_R" "PoleArm_R1";
    // Result: PoleArm_R1 //
    select -r FKXElbow_R ;
    select -add PoleArm_R1 ;
    doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
    parentConstraint -mo -weight 1;
    // Result: PoleArm_R1_parentConstraint1 //
    select -r IKArm_R ;
    duplicate -rr;
    // Result: IKArm_R1 //
    select -r IKArm_R1|IKXArmHandle_R ;
    delete;
    select -r Wrist_R ;
    select -add IKArm_R1 ;
    doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
    parentConstraint -mo -weight 1;
    // Result: IKArm_R1_parentConstraint1 //
    setAttr -lock true "FKElbow_R.rx";
    setAttr -lock true "FKElbow_R.rz";
    select -tgl IKArm_L IKArm_L1 ;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|IKParentConstraintArm_L|IKExtraArm_L|IKArm_L1.visibility;
    setAttr -lock false "IKArm_L1.v";
    setAttr "IKArm_L1.visibility" 0;
    select -tgl IKArm_R IKArm_R1 ;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|IKParentConstraintArm_R|IKExtraArm_R|IKArm_R1.visibility;
    setAttr -lock false "IKArm_R1.v";
    setAttr "IKArm_R1.visibility" 0;
    select -tgl PoleArm_L PoleArm_L1 ;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintArm_L|PoleExtraArm_L1|PoleArm_L1.visibility;
    setAttr -lock false "PoleArm_L1.v";
    setAttr "PoleArm_L1.visibility" 0;
    select -r PoleArm_R ;
    select -tgl PoleArm_R PoleArm_R1 ;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintArm_R|PoleExtraArm_R1|PoleArm_R1.visibility;
    setAttr -lock false "PoleArm_R1.v";
    setAttr "PoleArm_R1.visibility" 0;
    select -r PoleExtraLeg_L ;
    duplicate -rr;
    // Result: PoleExtraLeg_L1 //
    select -r PoleExtraLeg_L1|PoleLeg_L|PoleAnnotateTargetLeg_L ;
    delete;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintLeg_L|PoleExtraLeg_L1|PoleLeg_L.rotateX;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintLeg_L|PoleExtraLeg_L1|PoleLeg_L.rotateY;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintLeg_L|PoleExtraLeg_L1|PoleLeg_L.rotateZ;
    setAttr -lock false "PoleExtraLeg_L1|PoleLeg_L.rx";
    setAttr -lock false "PoleExtraLeg_L1|PoleLeg_L.ry";
    setAttr -lock false "PoleExtraLeg_L1|PoleLeg_L.rz";
    select -r FKXKnee_L ;
    select -r PoleExtraLeg_L1|PoleLeg_L ;
    rename "PoleExtraLeg_L1|PoleLeg_L" "PoleLeg_L1";
    // Result: PoleLeg_L1 //
    select -r FKXKnee_L ;
    select -add PoleLeg_L1 ;
    doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
    parentConstraint -mo -weight 1;
    // Result: PoleLeg_L1_parentConstraint1 //
    select -r IKLeg_L ;
    duplicate -rr;
    // Result: IKLeg_L1 //
    if (`objExists IKLeg_L1|IKFootIndexPivotLeg_L`){
    select -r IKLeg_L1|IKFootIndexPivotLeg_L;
    delete;
    };
    select -r Ankle_L ;
    select -add IKLeg_L1 ;
    doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
    parentConstraint -mo -weight 1;
    // Result: IKLeg_L1_parentConstraint1 //
    setAttr -lock true "FKKnee_L.rx";
    setAttr -lock true "FKKnee_L.ry";
    select -r PoleExtraLeg_R ;
    duplicate -rr;
    // Result: PoleExtraLeg_R1 //
    select -r PoleExtraLeg_R1|PoleLeg_R|PoleAnnotateTargetLeg_R ;
    delete;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintLeg_R|PoleExtraLeg_R1|PoleLeg_R.rotateX;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintLeg_R|PoleExtraLeg_R1|PoleLeg_R.rotateY;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintLeg_R|PoleExtraLeg_R1|PoleLeg_R.rotateZ;
    setAttr -lock false "PoleExtraLeg_R1|PoleLeg_R.rx";
    setAttr -lock false "PoleExtraLeg_R1|PoleLeg_R.ry";
    setAttr -lock false "PoleExtraLeg_R1|PoleLeg_R.rz";
    select -r FKXKnee_R ;
    select -r PoleExtraLeg_R1|PoleLeg_R ;
    rename "PoleExtraLeg_R1|PoleLeg_R" "PoleLeg_R1";
    // Result: PoleLeg_R1 //
    select -r FKXKnee_R ;
    select -add PoleLeg_R1 ;
    doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
    parentConstraint -mo -weight 1;
    // Result: PoleLeg_R1_parentConstraint1 //
    select -r IKLeg_R ;
    duplicate -rr;
    // Result: IKLeg_R1 //
    if (`objExists IKLeg_R1|IKFootIndexPivotLeg_R`){
    select -r IKLeg_R1|IKFootIndexPivotLeg_R;
    delete;
    };
    select -r Ankle_R ;
    select -add IKLeg_R1 ;
    doCreateParentConstraintArgList 1 { "1","0","0","0","0","0","0","1","","1" };
    parentConstraint -mo -weight 1;
    // Result: IKLeg_R1_parentConstraint1 //
    setAttr -lock true "FKKnee_R.rx";
    setAttr -lock true "FKKnee_R.ry";
    select -tgl IKLeg_L IKLeg_L1 ;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|IKParentConstraintLeg_L|IKExtraLeg_L|IKLeg_L1.visibility;
    setAttr -lock false "IKLeg_L1.v";
    setAttr "IKLeg_L1.visibility" 0;
    select -tgl IKLeg_R IKLeg_R1 ;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|IKParentConstraintLeg_R|IKExtraLeg_R|IKLeg_R1.visibility;
    setAttr -lock false "IKLeg_R1.v";
    setAttr "IKLeg_R1.visibility" 0;
    select -tgl PoleLeg_L PoleLeg_L1 ;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintLeg_L|PoleExtraLeg_L1|PoleLeg_L1.visibility;
    setAttr -lock false "PoleLeg_L1.v";
    setAttr "PoleLeg_L1.visibility" 0;
    select -r PoleLeg_R ;
    select -tgl PoleLeg_R PoleLeg_R1 ;
    setAttr -k on |Group|Main|MotionSystem|IKSystem|IKHandle|PoleParentConstraintLeg_R|PoleExtraLeg_R1|PoleLeg_R1.visibility;
    setAttr -lock false "PoleLeg_R1.v";
    setAttr "PoleLeg_R1.visibility" 0;
    string $ex = ("*" + "PoleExtraArm_L1");
    if (`objExists $ex`){
    button -edit -en 0 -l "you have add Match feature already" addmatch;
    };
    string $ex = ("*" + ":" + "PoleExtraArm_L1");
    if (`objExists $ex`){
    button -edit -en 0 -l "you have add Match feature already" addmatch;
    };
    select -cl ;
    };




  • 相关阅读:
    linux 终端分屏命令vsp(转)
    ACE消息队列(转)
    iovec结构体定义及使用 (转)
    转: 写给想成为前端工程师的同学们 (from 360前端团队)
    转:苹果企业级开发者账号申请流程
    奇舞团的博客(360前端团队)
    腾讯开源组件
    转:android studio入门合集
    Raid分类说明 (from mongodb权威指南)
    转: linux下的自动对时
  • 原文地址:https://www.cnblogs.com/xe2011/p/2535594.html
Copyright © 2011-2022 走看看