Home Technical Talk

Maya Mel Script Help

Eh all,

So, my knowledge with mel scripting is very limited but I figured out the basics of the script at the bottom of this link http://ndhaussy.free.fr/maya_object_spreading/ where Nicolas shows how to spread using constraints. So I type the command spreadObjectsOnSurface ("objectB", "objectA", 20) and it works as expected.

Now comes my question, because I have no idea how to even word it to find what I need to know using Google (I've tried with no close luck). Say I have 20 copies of objectB on objectA using the command above, but now I want 6 objectC on every objectB, how would I type this command?? I assume I need to know something about using a variable of some sort??

Thanks everyone

Replies

  • Deadly Nightshade
    Options
    Offline / Send Message
    Deadly Nightshade polycounter lvl 10
    Are you talking about recursion perhaps?
  • Evohc
    Options
    Offline / Send Message
    ^ Yah, maybe. Basically I want the command to tell Maya that for objectB1 to objectB20, duplicate 6 objectC on each. If I'm making sense.

    I'll look up recursion, but any more help someone might have would also be great, thanks!
  • AdvisableRobin
    Options
    Offline / Send Message
    AdvisableRobin polycounter lvl 10
    Recursion would be a solution, especially if you wanted to repeat that process a ton of times, but would also be complicated for someone new to programming. What you want to look into is called an Array, which is a variable that can store multiple 'data types'(including obejcts in the scene, numbers, letters, etc.) and loops. A loop basically will just be a way of telling a section of code to repeat until some condition is met.

    So, loop through an array of all the objectB's in the scene after they are created and then run the spreadObjectsOnSurface function until you've looped through the entire array of objectB's.

    Google up on arrays and loops.

    I have lots of experience with programming, but I ended up buying a video tutorial series from Eat3D for scripting in Maya and it was worth it. http://eat3d.com/maya_scripting
  • Evohc
Sign In or Register to comment.