Search code examples
pythonsimulationmaya

(hairSimulation/CFX) selecting multiple curves with its own duplicate and blendShape at the same time


In maya I am simulating hair and I want to lock the curves that are jittering. I duplicated those curves to make blend shapes, but there are too many to blend shape them individually. Is there a way to script to solve this? I think the way is to slice to get the name/number of the curves and blendShape all of them with a loop. But since I'm new to scripting I need help.


Solution

  • You can get follicles with this command :

    fols = cmds.ls(type='follicle')
    

    After that, find the curves simulated :

    crvs = cmds.ls(fols, dag=True, type='nurbsCurve')
    

    Loop through those curves and use :

    dup = cmds.duplicate(c)[0] # where c is the iterator of the for loop on crvs
    

    then :

    bs = cmds.blendShape(dup, c)
    

    You have few flags on every command but it should help you like name, weight and few more. I don't have maya for few weeks so I hope it will help you

    EDIT : Not that follicle curves are set as intermediate, for blendshaping, you might need to temporarly set them :

    cmds.setAttr(c+'.io', 0)
    bs = cmds.blendShape(dup, c)
    cmds.setAttr(c+'.io', 1)