Home Coding, Scripting, Shaders

Maya replicate along curve with MASH script

polycounter lvl 6
Offline / Send Message
m00k polycounter lvl 6
Hey guys I'm writing the script in the title but I've run into some issues. The script works once but once other mash networks enter the fray it fails since I don't know how to indicate which one to use. I can't find any decent MASH documentation.

  1. # Curve replicator


  2. #TODO

  3. # alter mash network name

  4. #add support for other curves


  5. import MASH.api as mapi

  6. import maya.cmds as cmds



  7. selection = cmds.ls (selection = True);

  8. shapes = cmds.listRelatives (shapes = True)

  9. succes = 0


  10. cmds.select (cl = True)




  11. #sort selection

  12. if (len(selection) == 2):

  13. for shape in shapes:

  14. if (cmds.objectType(shape, isType = 'bezierCurve')):

  15. obCurve = selection[shapes.index(shape)]

  16. succes = succes+1


  17. elif (cmds.objectType(shape, isType = 'mesh')):

  18. print selection[shapes.index(shape)]

  19. ob = cmds.duplicate(selection[shapes.index(shape)], rr = True)

  20. succes = succes+2


  21. else:

  22. print 'object selected is not bezier or mesh, quiting'


  23. if (succes == 3):

  24. #Create mash network

  25. cmds.select (ob)

  26. mashNetwork = mapi.Network()

  27. mashNetwork.createNetwork(name = 'Replicator')

  28. mashNetwork.addNode('MASH_Curve')

  29. cmds.connectAttr(obCurve + '.worldSpace[0]', 'MASH1_Curve' + '.inCurves[0]', force=1)


  30. #Print stuff

  31. print mashNetwork.waiter

  32. print mashNetwork.distribute

  33. print mashNetwork.instancer


  34. else:

  35. print 'selection incorrect, stopping...'






Sign In or Register to comment.