I'm trying to paste a saved skeleton pose onto an imported skeleton but am struggling to see how to use it correctly. I've been able to paste character poses onto the control rig using the following and want to do something similar:
cPoses = FBSystem().Scene.CharacterPoses thePose = cPoses[0] # the 1st pose in the list pChar = FBSystem().Scene.Characters[0] poseOptions = FBCharacterPoseOptions() thePose.PastePose(pChar, poseOptions)
Using:
poses = FBSystem().Scene.ObjectPoses
poseOptions = FBObjectPoseOptions()
objectPose = poses[0]
...but now I can't figure how to use PasteObjectPose or PasteTransform correctly; I'm getting errors whatever I feed them. Can I paste the pose onto all of the bones at once or must I do it on an array of all the bones in the hierarchy contained in the pose, got using say FBGetSelectedModels()?
Just to clarify further (as reading my post back it's not entirley clear), I am trying to paste a pose onto a skeleton before it has been characterized or had any control rig applied.
You would have to grab the selection of the skeleton and create the pose from that selection, then paste instead of getting the character nodes.
Brad Clark
Co-Founder:Rigging Dojo-Teaching the art and science of character rigging
Author: Inspired 3D Advanced Rigging
Author:The Character Animator Toolkit for Motionbuilder
Have the same issue. I have skeleton and pose for it, but i don't get how to paste it with python.
I can't use PastePose for character because i have no character yet, i tried to use PasteObjectPose but my pose is
FBPose and i get AttributeError: 'FBPose' object has no attribute 'PasteObjectPose'.
All i need is just click "Paste" button, but i stuck with it for a day cause i need to do it with python.
P.S.: I'm new in motionbuidler scripting and after maya it seems quite hard.
might help
http://forums.autodesk.com/t5/motionbuilder-forum/fbobjectpose-example/m-p/4189980#M8003
bindPose = FBObjectPose()
bindPose.Name = "test"
Brad Clark
Co-Founder:Rigging Dojo-Teaching the art and science of character rigging
Author: Inspired 3D Advanced Rigging
Author:The Character Animator Toolkit for Motionbuilder
Thank you for quick reply!
bindPose = FBObjectPose("Test")
fixed, it works fine now, so Doc is right.
I can create and work with FBObjectPose, but i have FBPose and trying to paste it. It seems to me that solusion is in 4th post of http://forums.autodesk.com/t5/motionbuilder-forum/trying-to-get-selected-pose-in-7-5ext2/td-p/407016...
So I'll try to use SetNodeMatrix() and SetNodeObject()
With apologies for necro-posting, but I'm currently in a similar - if not exactly the same - situation:
We have access to a skeleton and an FBPose object living in Pose Controls... and the seemingly straightforward task of
from pyfbsdk import * from pyfbsdk_additions import * import os app = FBApplication() player = FBPlayerControl() system = FBSystem() scene = system.Scene character = FBApplication().CurrentCharacter selectedModels = FBModelList() topModel = None selectionState = True sortBySelectOrder = True FBGetSelectedModels(selectedModels, topModel, selectionState, sortBySelectOrder) foundComponents = FBComponentList() includeNamespace = True modelsOnly = False FBFindObjectsByName('*_Face_BasePose', foundComponents, includeNamespace, modelsOnly) test_pose = None for comp in foundComponents: print comp, type(comp) test_pose = comp print test_pose test_pose.__class__ = FBObjectPose # tried this as FBPose not having 'paste' functions...
moreComponents = FBComponentList() includeNamespace = True modelsOnly = True FBFindObjectsByName('*_Eye', moreComponents, includeNamespace, modelsOnly) for comp in moreComponents: test_pose.PasteObjectPose(comp.Name, comp)
scene.Evaluate()
... unfortunately the calls to PasteObjectPose comes back complaining about:
Boost.Python.ArgumentError: Python argument types in FBObjectPose.PasteObjectPose(FBObjectPose, str, FBModelSkeleton) did not match C++ signature: PasteObjectPose(class PYFBSDK::FBObjectPose_Wrapper {lvalue}, char const * __ptr64, class PYFBSDK::FBComponent_Wrapper {lvalue})
... which seems insane because everything derives from FBComponent, so then I checked good ol' TAO for the pyfbsdk_gen_doc to triple check that
def PasteObjectPose(self,pObjectName,pObject): """ Paste the pose of all the properties of an object. pObjectName : Name of the object stored in the pose. pObject : Object which will receive the values stored in the pose. """ pass
which also seems to imply that it really should *~just~* work as shown in the call
test_pose.PasteObjectPose(comp.Name, comp)
We're going forward with a brute force solution because time is not on our side, but if anyone can explain How FBPose or FBObjectPose pasting actually works, that would be great... and to clarify, No, we can't use/resort to CharacterPose
Further apologies for the double post, but a more succinct example of what the problem is:
# Open a Scene, find either stored or merge external poses # ... poses = system.Scene.ObjectPoses for pose in poses: # everything is returned as an FBPose... print pose.Name, pose test_pose = poses[0] test_pose.__class__ = FBObjectPose # Technically cast to FBObjectPose... but probably not a great idea selectedModels = FBModelList() FBGetSelectedModels(selectedModels, None, True, True) for s in selectedModels: try: test_pose.PasteObjectPose(s.Name, s) except Exception as e: print e ''' fails with:
Python argument types in FBObjectPose.PasteObjectPose(FBObjectPose, str, FBModelSkeleton) did not match C++ signature: PasteObjectPose(class PYFBSDK::FBObjectPose_Wrapper {lvalue}, char const * __ptr64, class PYFBSDK::FBComponent_Wrapper {lvalue}) most likely angry due to the forced cast ''' # whereas making a pose 'manually'... another_pose = FBObjectPose("Another_Pose") #... for s in selectedModels: another_pose.PasteObjectPose(s.Name, s) # "works", but completely defeats any ability to operate with previously saved / imported poses
Which version of MotionBuilder are you using? Your code worked fine in 2018 with a pose created with joints and models?
Below is a snippet that I think is doing what you are talking about - at least in MoBu 2018. I just added the merge options at the top in case that was breaking something, the rest is the same as your original post - I also add the Selection = True for "comp in foundComponents".
Only other thing I could think of is, "FBFindObjectsByName" is finding something that doesn't work with "PasteObjectPose".
Let me know if this helps,
Simon
from pyfbsdk import * ## Merge Pose File mergeOptions = FBFbxOptions( True ) # Discard all Elements. Discard all Animation mergeOptions.SetAll(FBElementAction.kFBElementActionDiscard, False) # Merge Poses mergeOptions.Poses = FBElementAction.kFBElementActionMerge # Discard All Settings mergeOptions.BaseCameras = False mergeOptions.CameraSwitcherSettings = False mergeOptions.CurrentCameraSettings = False mergeOptions.GlobalLightingSettings = False mergeOptions.TransportSettings = False # Turn off Open File window mergeOptions.ShowOptionsDialog = False # Path to Pose File poseFile_path = r"C:\Desktop\poseTst.fbx" # Merge Pose using file Merge options. fileMergeSuccess = FBApplication().FileMerge( poseFile_path, False, mergeOptions) if fileMergeSuccess: # Select Objects foundComponents = FBComponentList() includeNamespace = False modelsOnly = False FBFindObjectsByName('L_arm_*', foundComponents, includeNamespace, modelsOnly) # Select Components for comp in foundComponents: print comp, type(comp) # Select Objects comp.Selected = True poses = FBSystem().Scene.ObjectPoses for pose in poses: # everything is returned as an FBPose... print pose.Name, pose test_pose = poses[0] selectedModels = FBModelList() FBGetSelectedModels(selectedModels, None, True, True) for s in selectedModels: try: test_pose.PasteObjectPose(s.Name, s) except Exception as e: print e
A great !! I had not had time to look through the code, saw that this came up the other day again.
Brad Clark
Co-Founder:Rigging Dojo-Teaching the art and science of character rigging
Author: Inspired 3D Advanced Rigging
Author:The Character Animator Toolkit for Motionbuilder
Can't find what you're looking for? Ask the community or share your knowledge.