Jump to content
Sign in to follow this  
captainbuckfish

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

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×