Been learning some Motionbuilder Python API
admin 0 MotionbuilderScriptingAnd let me tell you it is frustrating as hell…. something as simple as just trying to connect the Translate Y of one attribute to another is like an insane amount of code. It literally makes you want to throw a chair at someone. Here’s a nice example for that simple connection:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
lConstraintRelation = FBConstraintRelation('Test') lConstraintRelation.Active = True A = FBModelNull('NullA') A.Show= True B = FBModelNull('NullB') B.Show= True sourceBox = lConstraintRelation.SetAsSource (A) convertBoxV2N = lConstraintRelation.CreateFunctionBox('Converters', 'Vector to Number') targetBox = lConstraintRelation.ConstrainObject (B) convertBoxN2V = lConstraintRelation.CreateFunctionBox('Converters', 'Number to Vector') #Link up the constraints, connecting Source Translation to converterBox Vector to Number first #Then connecting convertBoxV2N to converterbox Number to Vector, then finally #connecting just the Translate Y of converterBoxN2V to our Target Translate OUT = FindAnimationNode (sourceBox.AnimationNodeOutGet(), 'Translation') IN = FindAnimationNode (convertBoxV2N.AnimationNodeInGet(), 'V') if OUT and IN: print "Success1" FBConnect(OUT, IN) OUT = FindAnimationNode (convertBoxV2N.AnimationNodeOutGet(), 'Y') IN = FindAnimationNode (convertBoxN2V.AnimationNodeInGet(), 'Y') if OUT and IN: print "Success2" FBConnect(OUT, IN) OUT = FindAnimationNode (convertBoxN2V.AnimationNodeOutGet(), 'Result') IN = FindAnimationNode (targetBox.AnimationNodeInGet(), 'Translation') if OUT and IN: print "Success3" FBConnect(OUT, IN) |
Hope this helps someone!