[SOLVED]Multiple import .bvh with mocap tool (mhx)

Hello,

I have written a script that reads from a specific .txt all the actions that my imported models from make human are supposed to do…


bpy.ops.object.select_all(action='DESELECT')

# Open activityoutput.txt and import all the actions
f = open('./activityoutput.txt')
lines = [line.strip() for line in open('./activityoutput.txt')]

for line in f:
    # Check if it is action
    var = ","
    line = line.replace(' ', '-')
    if not var in line:
        if not line in interactions:
            if not line in actions:
                line = line.capitalize()
                line = line.replace('
', '')
                name = line + "_proxy"
                bpy.ops.object.select_name(name=name, extend = False)
                print("human")
                print(line)
            if line in actions:
                print("action")
                print(line)
                a = actions.index(line)+1
                print("actions[a] = " + actions[a])
                actions[a] = actions[a].replace('
', '')
                bpy.ops.mhx.mocap_load_retarget_simplify('EXEC_DEFAULT', filepath = './actions' + actions[a])
                bpy.ops.object.select_all(action='DESELECT')

    # Check if it is interaction (by checking if there is comma in the line)
    if var in line:
        # print("True")
        line = line.replace(' ,', ',')
        line = line.replace(' ', '-')
        line = line.replace('
', '')
        ls = line
        ls = ls.split(',')
        #bpy.ops.object.select_name(name=ls[0] + "_proxy", extend = False)
        #bpy.ops.object.select_name(name=ls[1] + "_proxy", extend = False)

    if line in interactions:
        print("Interaction")
        a = interactions.index(line)+1
        ls[0] = ls[0].capitalize()
        #bpy.ops.object.select_name(name=ls[0] + "_proxy", extend = False)
        print(interactions[a])
        #bpy.ops.mhx.mocap_load_retarget_simplify('EXEC_DEFAULT', filepath = './interactions' + interactions[a])
        #bpy.ops.object.select_all(action='DESELECT')
        a = interactions.index(line)+2
        ls[1] = ls[1].capitalize()
        print(ls[1])
        #bpy.ops.object.select_name(name=ls[1] + "_proxy", extend = False)
        print(interactions[a])
        #bpy.ops.mhx.mocap_load_retarget_simplify('EXEC_DEFAULT', filepath = './interactions' + interactions[a])
        #bpy.ops.object.select_all(action='DESELECT')
f.close()

But I get an error in bpy.ops.object.select_all(action=‘DESELECT’), although I run it through blender…

Do you have any idea what could I be doing wrong?

bpy.ops.object.select_all(action=‘DESELECT’) ### OK

bpy.ops.object.select_name(name=“Cube”, extend = False) ### not work blender 2.62
try this
bpy.ops.object.select_pattern(extend=False, pattern=“Cube”, case_sensitive=False) ### OK

Thanks for your time,

the problem was just that I had to switch in POSE mode


        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
        bpy.ops.object.select_all(action='DESELECT')

Are you in edit or pose mode? This will cause object.select_all to fail.
You can check whether an op will run by calling its poll method first, in this case


bpy.ops.object.select_all.poll()

EDIT . seems you worked it out for yourself.

Thanks a lot, though:)