I need to setup twist joints (these are leaf joints) in MB using Relation constraints. I know how to set these up manually but hit a wall when doing so through python. Here is a screen grab from the constraint settings of the manual approach:
I’ve managed to solve most of this. Here’s some of the code that does the same as my previous image regarding the nodes and connections:
#Create "Relation" Constraint
constriant_name = "Test_Twist_ConRel"
relation_constraint = FBConstraintRelation(constriant_name)
relation_constraint.Active = True # Turn constraint on!
#Set up driver jnt (it's a box in MB)
src_box = relation_constraint.SetAsSource(scr_jnt)
relation_constraint.SetBoxPosition( src_box, 0, 100 )# Set the box position within the constraint setting graph!
src_box.UseGlobalTransforms = False # makes translation/rotation local "Lcl"
#Set up driven jnt (it's a box in MB)
trgt_box = relation_constraint.ConstrainObject(target_jnt)
relation_constraint.SetBoxPosition( trgt_box, 1200, 100 )
trgt_box.UseGlobalTransforms = False # makes translation/rotation local "Lcl"
# Creates Vector to Number and Multiply (a x b) nodes (these are called boxes)
v2num_box = relation_constraint.CreateFunctionBox("Converters", "Vector to Number") # returns FBBox
relation_constraint.SetBoxPosition( v2num_box, 450, 200 )
num2v_box = relation_constraint.CreateFunctionBox("Converters", "Number to Vector") # returns FBBox
relation_constraint.SetBoxPosition( num2v_box, 800, 200 )
mutilpy_box = relation_constraint.CreateFunctionBox("Number", "Multiply (a x b)")
relation_constraint.SetBoxPosition( mutilpy_box, 600, 100 )
# Connect boxes------------------------------------------------------------------------------
src_box_Out = findAnimationNode( src_box.AnimationNodeOutGet(), "Lcl Rotation" )
v2num_box_In = findAnimationNode( v2num_box.AnimationNodeInGet(), "V" )
FBConnect( src_box_Out, v2num_box_In )# connect src_box (atrribute Lcl Rotation) to v2num_box_In ( attribute V)
v2num_box_Out = findAnimationNode( v2num_box.AnimationNodeOutGet(), "X" )
mutilpy_box_In = findAnimationNode( mutilpy_box.AnimationNodeInGet(), "a" )
FBConnect( v2num_box_Out, mutilpy_box_In )
mutilpy_box_Out = findAnimationNode( mutilpy_box.AnimationNodeOutGet(), "Result" )
num2v_box_In = findAnimationNode( num2v_box.AnimationNodeInGet(), "X" )
FBConnect( mutilpy_box_Out, num2v_box_In )
num2v_box_Out = findAnimationNode( num2v_box.AnimationNodeOutGet(), "Result" )
trgt_box_In = findAnimationNode( trgt_box.AnimationNodeInGet(), "Lcl Rotation" )
FBConnect( num2v_box_Out, trgt_box_In )
My problem is how to set the parameter for b [number] connection. This a float value used within the Multiply box. The following image shows this connection marked in red: