from motionbuilder_pipe.tools.attachment_rigger.ui import attachment_rigger_ui
from motionbuilder_pipe.tools.attachment_rigger import attachment_rigger
reload(attachment_rigger_ui)
reload(attachment_rigger)
attachment_rigger.main()
ik_gun_bone = get_object_by_name('ik_hand_gun')[0]
hand = get_object_by_name('hand_r')[0]
m4 = get_object_by_name('root', namespace='Prop')[0]
m9 = get_object_by_name('root', namespace='Prop 1')[0]
hand_control = get_object_by_name('RightWristEffector', namespace='Character_Ctrl')[0]
ctrls = [hand, m4, m9]
create_ik_constraint()
x = create_constraint(ik_gun_bone, ctrls, hand_control)
def GetGroupedObjects(groupName=str):
for comp in FBSystem().Scene.Components:
comp.Selected = False
for group in FBSystem().Scene.Groups:
if groupName == group.Name:
for n in range(group.GetSrcCount()):
group.GetSrc(n).Selected = True
GetGroupedObjects("SK_Export")
from pyfbsdk import FBConstraintRelation, FBModelMarker, FBConnect
def FindAnimationNode( pParent, pName ):
lResult = None
for lNode in pParent.Nodes:
if lNode.Name == pName:
lResult = lNode
break
return lResult
lConstraintRelation = FBConstraintRelation( 'AConstraintRelation' )
lModel = FBModelMarker( 'AModelMarker' )
lModel.Translation.SetAnimated(True)
lModel.Visible = True
lSineRampBox = lConstraintRelation.CreateFunctionBox( 'Sources', 'Sine Ramp' )
lConstraintRelation.SetBoxPosition( lSineRampBox, 30, 30 )
lNumberToVectorBox = lConstraintRelation.CreateFunctionBox( 'Converters', 'Number to Vector' )
lConstraintRelation.SetBoxPosition( lNumberToVectorBox, 400, 30 )
lPlaceHolderBox = lConstraintRelation.ConstrainObject( lModel )
lConstraintRelation.SetBoxPosition(lPlaceHolderBox, 700, 30)
lSineRampOut = FindAnimationNode( lSineRampBox.AnimationNodeOutGet(), 'Result' )
lNumberToVectorIn = FindAnimationNode( lNumberToVectorBox.AnimationNodeInGet(), 'Y' )
if lSineRampOut and lNumberToVectorIn:
FBConnect( lSineRampOut, lNumberToVectorIn )
lNumberToVectorOut = FindAnimationNode( lNumberToVectorBox.AnimationNodeOutGet(), 'Result' )
lModelIn = FindAnimationNode( lPlaceHolderBox.AnimationNodeInGet(), 'Translation' )
if lNumberToVectorOut and lModelIn:
FBConnect( lNumberToVectorOut, lModelIn )
lConstraintRelation.Active = True
ik_gun = get_object_by_name('ik_hand_gun')[0]
hand = get_object_by_name('hand_r')[0]
m4 = get_object_by_name('root', namespace='Prop')[0]
m9 = get_object_by_name('root', namespace='Prop 1')[0]
hand_control = get_object_by_name('RightWristEffector', namespace='Character_Ctrl')[0]
gun_constraint = create_parent_constraint('IK_Hd_2_gun', [hand, m4, m9], ik_gun)
gun_constraint.Lock = True
all_control_name = ['hand']
for i in [m4, m9]:
parent_name = [p.Name for p in i.Parents if type(p) is FBModelNull][0]
all_control_name.append(parent_name)
all_user_property = ['weight', 'IK_Match']
for control_name in all_control_name:
all_user_property.append(control_name + '_index')
for user_property in all_user_property:
_property = hand_control.PropertyList.Find(user_property)
if _property:
hand_control.PropertyRemove(_property)
prop = hand_control.PropertyCreate('IK_Match', FBPropertyType.kFBPT_enum, 'Enum', True, True, None)
enum_list = prop.GetEnumStringList(True)
for i in all_control_name:
enum_list.Add(i)
prop.NotifyEnumStringListChanged()
for i, control_name in enumerate(all_control_name):
property_name = control_name + '_index'
prop = hand_control.PropertyCreate(property_name, FBPropertyType.kFBPT_int, 'Integer', True, True, None)
prop.Data = i
prop = hand_control.PropertyCreate('weight', FBPropertyType.kFBPT_int, 'Integer', True, True, None)
prop.Data = 100