Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / Copying keys from one object to another
  RSS 2.0 ATOM  

Copying keys from one object to another
Rate this thread
 
63647
 
Permlink of this thread  
avatar
  • Total Posts: 25
  • Joined: 01 September 2006 07:16 AM

Hi guys,

I’ve a quick question:

How can I copy over keys from one object(e.g. FBModel-type) to another?

I manually can copy keys from one source object to another by selecting the keys in the FCurve editor and paste them onto the destination model.

What are my options here to do that with python?
Does anybody have any experiences with that?

My own suggestions:

1.) I’m saving out every key on each FCurve(T/R/S) with its time and value and reapply it to the FCurves of the destination object. Good ol’ way, but how fast is it?

2.) I’m basically creating a constraint(point/parent->zero) to get the right keys anyway, plot it down and delete it.

3.) This is the way that intrigues me the most. Is it possible to assign the animation-nodes of one object to another so they actually share the same data?

What do you think?

Cheers,

Chris



Replies: 0
avatar

Hi guys,

I’ve found the answer to my question as I was suggesting different approaches. ;)

It is possible to assign the FCurves of a certain model to another one in a very easy way.
Here’s the example code:

from pyfbsdk import *

mySource =  FBFindModelByName("cube_source")
myDestination =  FBFindModelByName("cube_destination")

print 
mySource.Name,myDestination.Name

myDestination
.Translation.GetAnimationNode().Nodes[0].FCurve mySource.Translation.GetAnimationNode().Nodes[0].FCurve
myDestination
.Translation.GetAnimationNode().Nodes[1].FCurve mySource.Translation.GetAnimationNode().Nodes[1].FCurve
myDestination
.Translation.GetAnimationNode().Nodes[2].FCurve mySource.Translation.GetAnimationNode().Nodes[2].FCurve

This is just the test environment and nothing special. A loop inside a copy function will be much nicer that’s for sure. ;)

I really hoped it works out this way instead of copying over every keyframe in a big loop.
Phew, lucky me. :)

By the way:
Besides my suggestion that both models will share the same FCurve data, actually they don’t. Each FCurve is on its own after copying over. Nothing is referenced. :)



Replies: 0