MotionBuilder Forum
Welcome to Autodesk’s MotionBuilder Forums. Share your knowledge, ask questions, and explore popular MotionBuilder topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

selecting all the bones in the scene

5 REPLIES 5
Reply
Message 1 of 6
SebastianFro
3706 Views, 5 Replies

selecting all the bones in the scene

Hi there,

I'm looking for a way too select, or somehow get all the bones in my character, so that i can apply the same changes on all of them. I'm thinking either somehow make the script look for all the bones in the scene, or find the root, and then get rest of the hierarchy. I'm sure it's easy but I cant figure out any of the two. Any help?

Thanks
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: SebastianFro

Are you wanting all the joints or just ones associated with a character?

You could use a recursive function that goes through the hierarchy and finds all objects that are FBSkeleton such as:


def searchAndSelectSkeleton(node):
if node.ClassName() == 'FBSkeleton':
node.Selected = True
for child in node.Children:
searchAndSelectSkeleton(child)


Unless you are doing something after the script is done, you don't need to select it to perform an action, you can simply just change the line 'node.Selected = True' to whatever you need to do.

To call this script you would just need to give it a starting point. Such as the root:

sceneRoot = FBSystem().Scene.RootModel
searchAndSelectSkeleton(sceneRoot)


I hope that helps what you are after,
Scott
Message 3 of 6
SebastianFro
in reply to: SebastianFro

doesnt seem to work for me. maybe im doing something wrong.

All I want to do is "freeze" the rotation of all the bones, by getting the rotation of each and copy it to the prerotation and then zero it.

I have it working like this, but I wanted to shorten the thing a bit, and learn how to get specific objects in a scene. The list gets quite long.


lrota = FBVector3d ()
def Freeze (lname, lorder):
lbone = FBFindModelByName (lname)
lbone.RotationActive = True
lbone.GetVector ( lrota, FBModelTransformationMatrix.kModelRotation, False, None)
lbone.PreRotation = lrota
lbone.RotationOrder = lorder
lbone.Rotation = FBVector3d ( 0, 0, 0)


Freeze ("Pelvis", FBModelRotationOrder.kFBEulerYXZ)...
Message 4 of 6
Anonymous
in reply to: SebastianFro

Oops, I didn't have a working copy of motionbuilder to test my function but it should be FBModelSkeleton not FBSkeleton.

This should work:


def searchAndSelectSkeleton(node):
if node.ClassName() == 'FBModelSkeleton':
node.Selected = True
for child in node.Children:
searchAndSelectSkeleton(child)


if your case what you can do is use the above code like I mentioned before but then change the line instead of node.Selected = True so it will call your function (with a minor change):


def searchAndFreezeSkeleton(node):
if node.ClassName() == 'FBModelSkeleton':
Freeze(node, FBModelRotationOrder.kFBEulerYXZ)
for child in node.Children:
searchAndFreezeSkeleton(child)

def Freeze (lbone, lorder):
lrota = FBVector3d ()
lbone.RotationActive = True
lbone.GetVector ( lrota, FBModelTransformationMatrix.kModelRotation, False, None)
lbone.PreRotation = lrota
lbone.RotationOrder = lorder
lbone.Rotation = FBVector3d ( 0, 0, 0)

searchAndFreezeSkeleton(FBSystem().Scene.RootModel)


Cheers,
Scott
Message 5 of 6
SebastianFro
in reply to: SebastianFro

Cool thanks. now it works, but doesnt freeze the root of the hierarchy. can just do that afterwards tough. no problem. thanks
Message 6 of 6

Hi,

 

I work in motion capture and I need to create a script to automate some processes, like selecting all the bones of all the character in a the scene except their face rig (which mean I would stop at the head node in the selection of the hierarchy).

I have some background in java and php but im new in python.

I am using Motion Builder 2014 and tried your small script just to select al for a start but it does no work for me. 

 

here is what I wrote in my editor 

 

from pyfbsdk import*

def searchAndSelectSkeleton(node):
if node.ClassName() == 'FBModelSkeleton':
node.Selected = True
for child in node.Children:
searchAndSelectSkeleton(child)
sceneRoot = FBSystem().Scene.RootModel
searchAndSelectSkeleton(sceneRoot)

I get an AttributeError: 'property' object has no attribute 'ClassName'

as well as NameError: name 'scene' is not defined


Could you help me?

Thanks


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report