How to Create Basic MEL Scripting in Maya 2017
Are you a 3d artist and feel that you cannot script? Well, I'm here to prove you wrong! Watch my video tutorial to see how easy it is to create a MEL script.
No downloads needed! Just your own models.
Software: Maya 2017
~~~~~~~~~~~~~~~ Show your support if you want to see more tutorials like this - click subscribe and share! https://www.youtube.com/user/academicphoenixplus
Find FREE downloads at my website! https://www.academicphoenixplus.com/
Keep up with me on FB : https://www.facebook.com/academicphoenixplus
I'm on Twitter too! https://twitter.com/academicphoenix
How to Create Basic MEL Scripting in Maya 2017
Hey guys, this is Monica at Academic Phoenix Plus and today I wanted to go over a bit of basic scripting, specifically with MEL.
If you don't know what MEL stands for, MEL stands for Maya Embedded Language. One of the things that artists think is that they can't do any type of scripting. The reality is that you can especially if it's something that you do over and over and over again. So modeling, for example, we have a tendency to create something and then move it around. Then go to Edit>Delete by Type>History, and then we go to Modify>Freeze Transformations. If we made any type of changes, we always want to go Modify>Center the Pivot. We end up doing that a great deal. These are the three steps that we have a tendency to continuously do which is Edit>Delete by Type>History, Modify>Freeze Transformations and Center the Pivot. What I wanted to show you was that we can quickly create a script that will make this process go a lot faster. Alright so let's go ahead and get started.
Over here on the right, we're going to go to our Script Editor. You can see that our Script Editor has a MEL and Python tab. We're going to be using MEL. What we're doing is called Procedural Scripting which means that it just goes by command, command, command, command. For example let's say I want to build a sphere. If I type “Sphere”, notice that it turned blue and it got italicized, which means that Maya recognizes it. I want to put in a semicolon which means that that is the end of my command. I'm going to do Control+A which means Select All, and then Control+Enter. You're going to see that it creates a NURBS sphere. I just wanted to demonstrate to you that up here at the top, make a NURBS sphere is the result. That's how easy MEL scripting is.
Let's say, for example, I want to Delete My History. Let's go and grab this plane. Notice that it’s selected it. Edit>Delete by Type>History. Notice that you don't see any type of command so what we need is what's called an Echo Command. Under History, there's an Echo All Commands which say, I actually want you to show me every move that I make. Now we can go to Edit>Delete by Type>History, right here you're going to see that there's a command called DeleteHistory. I'm going to go ahead and copy this and I'm going to paste it and it recognizes it, Now you can type it in yourself but I'm a person that spells things wrong a lot. Alright so that's our first line. Whoops you see how I just press ENTER and it makes it disappear? I'm going to undo. Shift+Enter and take me to the second line.
Next thing I want to do is go to Modify>Freeze Transformations and you can see right here, there's FreezeTransformations. I'm going to go ahead and copy that paste it, Shift+Enter to the next line.
Finally I'm going to go to Modify>Center Pivot. There it is, CenterPivot. Control+C, Control+V. There we go.
Let's see if this actually work. Here's an item. It's got history, it's got transformations and here is the pivot so we're going to do a Ctrl+A, Ctrl+Enter and there you go. Just like that you have Deleted History, Froze Transformations and Center the Pivot. Awesome. Now of course we don't really want to go through that every single time we want to do this. So instead what we're going to do is make a button and Maya is actually set up for this. So let's go to Custom Bar. Custom is where you can create your own buttons. It's really pretty easy. You just select this, then I'm going to middle mouse and drag this text into my Custom Bar up here. Let it go and right here is going to have a new icon. so I'm going to close this. When I select this piece of geometry, you can see that it's got some history, you can see that it's got information on translate and scale. I click on that and right away everything changes.
I'm going to Right Click on this. I'm going to go to Edit, and under command it shows you that you can make some changes to the script if you want to. The command is not written in stone. You can always alter it if you want to. I'm going to go to Shelves and Shelves has information about your button. For example, let's say that I want to go ahead and do an icon label, say I'm going to call this CMND which stands for command. Over here and right away you can see this is CMND. Now it does have limitations. You can only put in about 4 letters so keep that in mind.
Other things you can do to make this a little bit more unique is change the text. Let's say you want to change it to blight blue. You can change the background so let's say you want to change that to something crazy like red or not. It's up to you. What you can also do is choose a custom background so if you want to make it stand out a little bit more, you can. Do whatever you like.
You can create your own icon. If you click on this little folder, you're going to see that it's going to look for some icons under C:admin/documents/maya/2017/preference/icons. So if you wanted to create your own button you can. I'll show you how to make one. Let's go ahead and open up Photoshop. It is going to be a tiny little button. It's going to be a custom and it's going to be 52 by 52. Yes it is a tiny little button. I'm going to go ahead and maybe fill this in with some sort of color. Personally I like blue, so I'm going to go for blue. Maybe I want to have a shadow, go down, make it a little darker so it's a little bit more noticeable. Maybe a little bit more angled, there you go. I want to call this CMD and I can go crazy with this but it's up to you. What else, you want to do maybe use a color overlay and change the color. I'm happy with the results. Go ahead and flatten the images, Ctrl+Shift+S.
Back in Maya, we're going to go to my C:admin/documents/maya/2017/preference/icons. This is going to be my command. There it is. Just like that if I want to delete this and there you go. So now if I have any type of information I can come over here. You can always click on this command and it will quickly remove the history, freeze the transformations, Center the pivot. By the way, don't be limited. You can always select all these pieces and press that magical button and automatically it will Center the pivot, delete the history, and freeze the transformations.
Alright that is scripting 101. Very simple, very fast. You can create your own custom bar. You can create your own custom scripts. You can create your own custom icon and you can do all sorts of things with this. This will save you about five seconds but we use this all the time, when we're creating models, rigging or anything. So this is going to save you tons of time in the long run. I definitely encourage you to explore MEL.
I hope you found this helpful. Don't forget to subscribe to my channel. Also tell me what you think. What would you like to see more. Do you want to see more modeling, do you want to see more texturing, lighting, rigging? Let me know. Share my videos with your friends.
Alright and I will see you next time.