from pyfbsdk import *
def IsConnectedTo(to, toConnect):
for i in range(to.GetSrcCount()):
if to.GetSrc(i) == toConnect:
return True
return False
def AssignRigidBodyToSelectedModels(rigidBody):
lModelList = FBModelList()
FBGetSelectedModels( lModelList )
if len( lModelList ) == 0:
FBMessageBox( "Message", "Nothing selected", "OK", None, None )
else:
modifiedmodels = []
for model in lModelList:
if not IsConnectedTo(model, rigidBody):
model.ConnectSrc(rigidBody)
modifiedmodels.append(model)
lMessage = "Models modified:"
lMessage += ''.join( map( lambda pModel: "\n" + pModel.Name, modifiedmodels ))
FBMessageBox( "Message", lMessage, "OK", None, None )
for p in FBSystem().Scene.PhysicalProperties:
if p.ClassName() == "KxL_RigidBodyProperty":
AssignRigidBodyToSelectedModels(p)
break