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: 

Relation Constraint FCurve (%)

5 REPLIES 5
Reply
Message 1 of 6
dnorthcutt
1001 Views, 5 Replies

Relation Constraint FCurve (%)

Hey Guys,

I'm writing some tools right now to drive bone rotation via a Relation Constraint. I've got everything mostly worked out with creating and connecting nodes in the constraint - but I'm having a bit of trouble with the FCurve (%) node. Does anyone know how to add/modify keys on one of these via script? Any help or ideas would be appreciated. Thanks!
5 REPLIES 5
Message 2 of 6
cmot
in reply to: dnorthcutt

As far as I know, the boxes in a Relation constraint are not animatable. This makes sense considering a Relation constraint is kind of like an expression you create through nodes instead of writing lines of code.

You can set the value of the input of the box if you want through something like this.


def FindAnimationNode( pParent, pName ):#standard find animation node def
lResult = None
for lNode in pParent.Nodes:
if lNode.Name == pName:
lResult = lNode
break
return lResult

constr = None
box = None

for thisConstr in FBSystem().Scene.Constraints:
if "Relation" == thisConstr.Name:
constr = thisConstr

if constr:
for thisBox in constr.Boxes:
if "FCurve Number (%)" == thisBox.Name:
box = thisBox
print box.Animatable #this shows up as False

if box:
nodeToSet = FindAnimationNode(box.AnimationNodeInGet(),"Position %")
nodeToSet.WriteData()


In scene with a relation constraint named "Relation" with a box in the relation constraint named "FCurve Number (%)"

I usually make a def like FindConstraint(constrName) and FindBox(constraint,boxName) when working with stuff like this.
Message 3 of 6
dnorthcutt
in reply to: dnorthcutt

Hey, thanks for the reply. I've got all the box building and connecting working -- I guess I was just hoping to automate the process of setting the keys within an FCurve box. Sounds like maybe it's not accessible via Python?
Message 4 of 6
middlek
in reply to: dnorthcutt

Do you mean this ?

KRISTINE MIDDLEMISS | SENIOR MOTION CAPTURE ENGINEER
Message 5 of 6
middlek
in reply to: dnorthcutt

Re-reading your post I think this is what you are looking for:


from pyfbsdk import *

def FindAnimationNode( pParent, pName ):
lResult = None
for lNode in pParent.Nodes:
if lNode.Name == pName:
lResult = lNode
break
return lResult

lRelation = FBConstraintRelation('TEST')

lFcurveBox = lRelation.CreateFunctionBox( 'Other', 'FCurve Number (%)' )
lValue = FindAnimationNode( lFcurveBox.AnimationNodeOutGet(), 'Value' )
lCurve = lValue.FCurve
lCurve.EditBegin()
lTime = FBTime( 0, 0, 0, 20 )
lKey = lCurve.KeyAdd( lTime, 20 )
lKeyFrame = lCurve.Keys
lKeyFrame.RightDerivtive = 7
lKeyFrame.LeftDerivative = 7
lCurve.EditEnd()


~Kristine
KRISTINE MIDDLEMISS | SENIOR MOTION CAPTURE ENGINEER
Message 6 of 6
dnorthcutt
in reply to: middlek

That's exactly what I was looking for - thanks a ton!

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

Post to forums  

Autodesk Design & Make Report