def get_next_free_mult_index(attr):
"""For given mutlindex attribute, returns the next available index.
Arg:
:attr, (str): node.attr
Returns:
:int:
"""
used_indexes = cmds.getAttr(attr, multiIndices=True)
return int(used_indexes[-1] + 1) if used_indexes else 0
def add_curve_to_loa(curve_list=None,zFiber=None):
selection_list = cmds.ls(sl=True)
if not curve_list and not zFiber:
curve_list = [selection_list[0]]
print curve_list
zFiber = selection_list[-1]
if not cmds.objectType(zFiber,isType='zFiber'):
zFiber= mel.eval('zQuery -t zFiber %s'%zFiber)[0]
print zFiber
if cmds.objectType(zFiber,isType='zFiber'):
loa = cmds.listConnections(zFiber,p=False,s=True,type='zLineOfAction')[0]
if loa :
attr='%s.curves'%loa
for curve in curve_list:
index = get_next_free_mult_index(attr)
shape=cmds.listRelatives(curve,s=True)[0]
print index
cmds.connectAttr('%s.worldSpace[0]'%shape,'%s[%s]'%(attr,index),f=True)
else:
print 'no loa found'
add_curve_to_loa()
to add an another curve to a zFiber lineOfAction
select the curves then the LOA and execute :
add_curve_to_loa()
(I don't know why tabs don't works well)