Mel Script questions


#1

Hey guys,

couple of questions. First, what would be best for setting up personal tools? Creating a Mel GUI, or just doing a custom shelf? I have begun creating a GUI, thinking this would be easiest for what I want to do, and have run into a few issues on the set up of some of my buttons. Some buttons I would like to create for example would be Offset Edge Loop tool, but I can’t seem to get it to operate correctly. Another issue I am having is a button that would create a smoothed cube. The cube creation works if I just type in the command CreatePolygonCube; Smooth Polygon;. This creates my cube exactly how I want it. When I issue my button command it does not work. Any suggestions?


#2

I use custom menus for my custom tools and shelves for the tools I use a lot.

Your script doesn’t work because CreatePolygonCube needs feedback to be created.
You would need to create a cube with specific settings like:

//mel
polyCube -ch on -o on -w 4 -h 4 -d 4 -cuv 4 ;
SmoothPolygon;

#3

Thanks Myara. I will try that out. I always thought that if you just input in the polycube command that it would initiate everything at the default levels of the cube. Strange though that if I just type in createpolygoncube; smoothpolygon; into the mel line that it creates what I want, but just doesn’t work when running it in the gui and clicking the button. It just creates the cube without the smooth. Hopefully changing the code with the info you provided will fix it! Much appreciated!


#4

Interesting, your initial button should work just fine…just checked it)


#5

If you use the command, CreatePolygonSphere it will depend on the Interactive Creation setting on your Create > Polygon Primitives Menu.

If it is on, then it will need a feedback.

If it is off, then it will create a sphere with the default settings.

Now, if you use the command polyCube, it won’t depend on anything and do what you tell it to.
I recommend to use the commands that are in the mel help and don’t rely on undocumented commands like CreatePolygonSphere unless it is necessary.

You can also check if the command is a mel script with:

whatIs("nameOfTheCommand")

If it is a mel, it will give you a path to the mel script. You can open that mel and study it.
If it is a embedded command, then you can’t see the code.

Ex:

For the command Delete Non-Deformer History, execute in mel:

whatIs ("doBakeNonDefHistory");

And you’ll get:

// Result: Mel procedure found in: C:/Program Files/Autodesk/Maya2016/scripts/others/doBakeNonDefHistory.mel //