Hi,
I have this issue where MotionBuilder quite often gives me “old” data. when I’m talking to it from Python. E.G.:
[ul]
[li]When I go to a frame, evaluate the scene and ask for transform data, it will sometimes give me data that is not current (in this case, not the transforms on that keyframe)
[/li]
[li]The same goes for the output of RelationConstraint networks that sometimes do not output the correct value for the frame you are on
[/li]
[li]The issue is seen when running a block of code, where using FBSystem().Scene.Evaluate() should give you current data. But I also see it in scenarios where I attach a function to UiIdle and dump data on that event (Similar to c++ exporter examples that come with MoBu)
[/li][/ul]
The people working in c++ have the issue too. We suspect that it has something to do with MotionBuilders “realtime” nature and that MoBu would rather return something to you (correct or not) rather than “hang”. Of course in a ton of situations, this would be a very bad thing.
So is anyone else seeing this? Do you have a remedy? This has more than slightly hampered our ability to do tools, let alone on schedule :tear:
Here’s a simple test to check if the issue occurs on a particular machine. I ran this on 7 different machines, including 2 home computers that have nothing in common with our work machines set-up. 4 out of 7 had the problem…
If you would like to reproduce, please run the test below:
"""
Creates a locator in scene and animates it at 0,0,0 - 0,10,0, over the course of frames 0-10
Then goes to frame 9 (could be any frame other than frame 10), then to frame 10 and reads the
Y translation of the locator. The Y translation should be 10. If it's not prints out a warning.
If you are not getting errors, you may want to run this test multiple times or to increase
the number of iterations through the loop. Could be that you just have a system to does not
have the issue. Though the people that use your tools may.
Sometimes I can run the test multiple times without errors, though mostly I get a few. Regularily
I'll get a really high error count. Like 49 or 87. I've gotten 998 & 999 errors (with 1000 loops) on occation!
"""
from pyfbsdk import *
lVector = FBVector3d()
totalErrors = 0
# Set frame range
startFrame = FBTime(0,0,0,0)
endFrame = FBTime(0,0,0,10)
FBPlayerControl().LoopStart = startFrame
FBPlayerControl().LoopStop = endFrame
FBPlayerControl().ZoomWindowStart = startFrame
FBPlayerControl().ZoomWindowStop = endFrame
# Create a locator and animate it
loc = FBModelNull('test_loc')
loc.Show = True
loc.Selected = True
FBPlayerControl().Goto(startFrame)
FBPlayerControl().Key()
FBPlayerControl().Goto(endFrame)
FBSystem().Scene.Evaluate()
loc.SetVector(FBVector3d(0, endFrame.GetFrame(False), 0), FBModelTransformationMatrix.kModelTranslation, True)
FBSystem().Scene.Evaluate()
FBPlayerControl().Key()
# Set curve interpolation to linear
for animNode in loc.AnimationNode.Nodes:
for subnode in animNode.Nodes:
for key in subnode.FCurve.Keys:
key.Interpolation = FBInterpolation.kFBInterpolationLinear
for i in range(0, 1999):
# Go to frame 9 and then to frame 10 where the locator is at 10, 0, 0
FBPlayerControl().Goto(FBTime(0,0,0,9))
FBSystem().Scene.Evaluate()
FBPlayerControl().Goto(FBTime(0,0,0,10))
FBSystem().Scene.Evaluate()
# Read and print the locators location
loc.GetVector(lVector, FBModelTransformationMatrix.kModelTranslation, False, None)
# If the locator is not at 10 in Y, let me know
if lVector[1] != 10:
print 'Y Translation at frame 10 at iteration {0} is:{1}'.format(i, lVector[1], )
totalErrors += 1
if totalErrors:
print 'Total errors were: {0}'.format(totalErrors)
else:
print 'Congratulations there were no errors'
loc.FBDelete()
Thanks