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: 

Set Value in Relation Constraint

15 REPLIES 15
Reply
Message 1 of 16
CountZr0_1
2533 Views, 15 Replies

Set Value in Relation Constraint

Anybody have a clue on how to 'Set Value' for a static channel in an FBBox inside a relation constraint?


lRelation = FBConstraintRelation("test")
lRelation.SetActive(True)

lBox = lRelation.CreateFunctionBox( 'Number', 'Multiply (a x b)')
inPlugs = lBox.AnimationNodeInGet()
staticPlug = inPlugs.Nodes

staticPlug.KeyAdd(5.0)


Doesn't seem to set the value. Any ideas?

Thanks,

-jason
-jason
15 REPLIES 15
Message 2 of 16
mondog_1
in reply to: CountZr0_1

Hi,

I needed this too couldn't get it to work either.

What i had to do was create nulls with the values i needed, on various channels. Then adding those into the relation tool via the script. It's a tad inelegant for sure but it did have the benefit of allowing me to alter these values in the scene, avoiding the update bug present in the relations tool

Mondo
Message 3 of 16
CountZr0_1
in reply to: CountZr0_1

Mondog,

OK. Thanks. That would work. Ugly as hell but it will do. Guess we could hide the nulls to keep it clean. Could even use one null to set as many values in a relation constraint as we would need by creating custom attributes on it, setting, and connecting those.
-jason
Message 4 of 16
_KxL_
in reply to: CountZr0_1

I toke a quick look at this case and find a half of solution in ORSDK (I was able to set and read static value, but unfortunatly did not found a way to enable it. Maybe becouse of lack of time). Unfortunatly functions ReadData and WriteData for FBAnimationNode are not expose in python. That's why I left farther investigation. I think, that in this case solution with a null is a reasonable solution.
Message 5 of 16
mondog_1
in reply to: CountZr0_1

Hi,

I thought i'd resurect this as it seems that this is possible in ext 2b.

The readme states that SetCandidate and WriteData are now exposed. I can't find any documentation on SetCandidate outside of the ORSDK docs and i can't figure out to set this up.

I tried the code snip that Jason posted previously and variations on this (for a scale and offset box):


inPlug = FindAnimationNode(mRHandScOffBoxA.AnimationNodeInGet(), 'Offset')
inPlug.SetCandidate = True


I get no errors with this, but i'm kind of clutching at straws - any ideas?

Thanks
Mondo
Message 6 of 16
CountZr0_1
in reply to: CountZr0_1

Yep,

Autodesk exposed the WriteData method for me so I could finish writing my Maya DrivenKey importer.

WriteData works like this:


inPlug = FindAnimationNode(mRHandScOffBoxA.AnimationNodeInGet(), 'Offset')
inPlug.WriteData = 10.0


Not really sure what the KeyCandidate() does.

Keep an eye out, I'll be posting my DrivenKey importer script on here soon.
-jason
Message 7 of 16
_KxL_
in reply to: CountZr0_1

Good to know that I was on the rigth way to do this...Thanks for info Jason!
Unfortunately I will not be able to test this new Ext2b...

Cheers.
Message 8 of 16
_KxL_
in reply to: CountZr0_1

And I can't wait to see your script Jason!
Message 9 of 16
mondog_1
in reply to: CountZr0_1

Set Driven Key importer sounds ace, i'm looking forward to seeing it.

Thanks for posting the method, unfortunately I still can't get it to work, i'm running ext2b build 05/15/2008. I get no errors but it resolutely refuses to set the value.

i'll try re-installing the update.
Mondo
Message 10 of 16
mondog_1
in reply to: CountZr0_1

So after a full re-install of ext2b, i'm still not getting any values to write to the box...

i've queried the box and it's definitely found the correct channel to write data to. This is the full code i'm using, uncluding the FindAnimationNode definition from the course notes:

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

#The relations constraint:
mConstraintRelation = FBConstraintRelation( 'RollBones' )

# Create scale offset box
mLHandScOffBoxA = mConstraintRelation.CreateFunctionBox( 'Number', 'Scale and Offset (Number)' )
inPlugs = FindAnimationNode(mLHandScOffBoxA.AnimationNodeInGet(), 'Offset')
inPlugs.WriteData = 10.0
Message 11 of 16
CountZr0_1
in reply to: CountZr0_1

mondog,

Guess WriteData needs to have a dictionary passed as a parameter (because it is a Member Function, not a Public Attribute):


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

#The relations constraint:
mConstraintRelation = FBConstraintRelation( 'RollBones' )

# Create scale offset box
mLHandScOffBoxA = mConstraintRelation.CreateFunctionBox( 'Number', 'Scale and Offset (Number)' )
inPlugs = FindAnimationNode(mLHandScOffBoxA.AnimationNodeInGet(), 'Offset')
inPlugs.WriteData ()


Sorry, my Python documentation did not update when I installed 2A or 2B so I didn't have the exact syntax. Sorry to put you through all the trouble. (But whenever I have to do that, it usually makes me understand the topic and documentation a lot better, so better for the long run, I guess.)

Good luck,
-jason
Message 12 of 16
mondog_1
in reply to: CountZr0_1

Brilliant, thanks Jason - works a treat!

Mondo
Message 13 of 16
Anonymous
in reply to: CountZr0_1

Hi,

When I try this "set Value" I got an issue. The Python Console give me this error:
>>>
Traceback (most recent call last):
file "z:\test\test02.py", line 18, in ?
inPlugs.WriteData ()
AttributeError: 'FBAnimationNode' object has no attribute 'WriteData'

from pyfbsdk import *
##################################
#Function
##################################
def FindAnimationNode( pParent, pName ):
lResult = None
for lNode in pParent.Nodes:
if lNode.Name == pName:
lResult = lNode
break
return lResult
#
test = FBConstraintRelation("test_1")
#
nBoxSaO_1 = test.CreateFunctionBox( 'Number', 'Scale And Offset (number)')
#
inPlugs = FindAnimationNode(nBoxSaO_1.AnimationNodeInGet(), 'Offset')
inPlugs.WriteData ()
Message 14 of 16
Anonymous
in reply to: CountZr0_1

My bad, I was still on Ext 2 not 2b 😛
Message 15 of 16
amayala
in reply to: mondog_1

Still unable to set values in box

Message 16 of 16
April.V.Warren
in reply to: amayala

Did you try 

 

animNode.WriteData([myvalue])

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

Post to forums  

Autodesk Design & Make Report