Deselect in motionbuilder python

So here’s an interesting one for any motionbuilder scripters out there.

if you do a .HardSelect() on a model. Is there a way to hard deselect it? I couldn’t find a solution.

basically I have a script that selects handles to apply animation to a body rig and a face. It has to
be hard selected because of how the library my studio is set up. but when i select another handle,
I can’t deselect the orignal so I get the animation loaded onto the 2 rigs.

example:

def importAnimation(handleName):
handle = FBFindObjectByFullName(handleName) ## motionBuilder class
handle.HardSelect()

selRig = getSelectedRigs() ## how the tool gets rigs

loadAnimation(selRig, path) ##load animation class from studio

So when I run this again with a different handle name it will have 2 handles selected. the original and the new one.

you’ll probably want a deselect function for that.


def deselectAll ():
    selectedModels = FBModelList()
    FBGetSelectedModels ( selectedModels, None, True )
    for select in selectedModels:
        select.Selected = False;
    del ( selectedModels )

Also I would recommend just using the following in your script.

handle.selected = True

So, i’m guessing you’ll want something that looks like this…


def deselectAll ():
    selectedModels = FBModelList()
    FBGetSelectedModels ( selectedModels, None, True )
    for select in selectedModels:
        select.Selected = False;
    del ( selectedModels )

def importAnimation(handleName):
    handle = FBFindObjectByFullName(handleName) ## motionBuilder class
    handle.HardSelect()

    selRig = getSelectedRigs() ## how the tool gets rigs

    loadAnimation(selRig, path) ##load animation class from studio

    deselectAll()
    # If you don't want to deselectAll, uncomment the following line to only deselect the current "handle"
    # handle.selected = False

Hope this helps