Jump to content

FK IK match script error


Recommended Posts

Been trying to rig in Houdini, went through the rigging series which was decent but the script for Matching FKIK comes up with an error when I execute it.

If you didn't see the video series. This is on the last video. Inside the HDA there is a parameter button created with the callback script  hou.pwd().hdaModule().matchIK(kwargs,"arm")

This is the code

def matchIK(kwargs,type):

    if kwargs["script_parm"][0] == "L":
        side = "L"
    else:
        side = "R"
    prefix = side + "_" + type
    asset = kwargs["node"]
    bone1 = hou.node(asset.path() + "/" + prefix + "bone_1")
    bone2 = hou.node(asset.path() + "/" + prefix + "bone_2")
    fkcontrol1 = hou.node(asset.path() + "/" + prefix + "_bone_1_ctrl")
    fkcontrol2 = hou.node(asset.path() + "/" + prefix + "_bone_2_ctrl")
    fkcontrols = [fkcontrol1, fkcontrol2]
    bones = [bone1, bone2]
    if type == "leg"
        prefix = side + "_" + "foot"
        bone3 = hou.node(asset.path() + "/" + prefix + "_bone_1")
        bone4 = hou.node(asset.path() + "/" + prefix + "_bone_2")
        fkcontrol3 = hou.node(asset.path() + "/" + prefix + "_bone_1_ctrl")
        fkcontrol4 = hou.node(asset.path() + "/" + prefix + "_bone_2_ctrl")
        bones.append(bone3)
        bones.append(bone4)
        fkcontrols.append(fkcontrol3)
        fkcontrols.append(fkcontrol4)
    for i, fkcontrol in enumerate(fkcontrols):
        curbone = bones
        bonepath = "/".join(curbone.path().split('/')[2:])
        iksolver = curbone.node(curbone.parm("solver").eval())
        chopstring = 'chop("' + iksolver.path() + '/' + bonepath
        chans = ["rx", "ry", "rz"]
        for chan in chans:
            if abs(hou.hscriptExpression(chopstring + ':' + chan + '")')) < 0.0001:
                rot = 0.0
            else:
                rot = hou.hscriptExpression(chopstring + ':' + chan + '")')
            if not fkcontrol.parm(chan).islocked():
                fkcontrol.parm(chan).setPending(rot)

 

Error says line 16, in matchIK
AttributeError: 'NoneType' object has no attribute 'path'

 

Im fairly clueless when it comes to scripting just wanted to be able to match IK Fk.

 

Help would be appreciated as would any advice on places to start with python scripting.

 

Many thanks,

 

Duncan

 

 

Link to comment
Share on other sites

  • 2 months later...

Just make sure you are accurate with your typing out.
The line above it has an error which prevents working through the list of bones.

curbone = bones

It should be:

curbone = bones[i]

 

Edited by DaFiNNiGaN
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...