Hey guys,
The question is simple for those with basic MEL knowledge I guess.
How do I toggle between the smoothed and non-smoothed version in Maya? I looked everywhere, and it doesn't appear to be possible to assign this to a hokey, so I assume I must do this with MEL?
I know people use 1, 2, 3 on the keyboard, but coming from Max I assigned those keys to vert, edge and poly respectively and I lost the options.
TL: DR, I want a hotkey that gives me the same result as the option highlighed in blue.
Replies
The mel command associated with this is subdivDisplaySmoothness , use -smoothness to define which level you want (1,2,3)
// toggle smooth mesh preview for selection
// get selected mesh nodes
string $sel[] = `ls -sl -dag -lf`;
// set attributes
for ($s in $sel) {
int $v = `getAttr ($s+".displaySmoothMesh")`;
int $w = `getAttr ($s+".smoothLevel")`;
if ($v == 0) $v = 2; else $v = 0;
if ($w == 0) $w = 1;
setAttr ($s+".displaySmoothMesh") $v;
setAttr ($s+".smoothLevel") $w;
}
Also if your coming from max, I know one thing that really bothered me when I started doing sub-d modeling in Maya, was an easy way to hide the wireframe of objects without having to deselect them (makes it hard to judge the curves of your sub-d modeling when it's visible, and it's annoying having to deselect things all the time).
Here's a quick script to do that, maybe you'll find it useful as well.
string $wires = `displayPref -q -wsa`;
if ($wires == "none")
displayPref -wsa "full";
else
displayPref -wsa "none";
Just tested it out Bal and worked with multiple selections (it should cause I go through all of them with the for loop.) Anywho fixed up the code cause Maya by default makes objects with a subdivision level of 0
This is awesome, I was looking for this! This is basically the F4 key in max, super useful thanks!
fade1, I couldn't get your script to work for some reason. Going in the hotkey editor and selecting the right options under Miscellaneous worked for me, it also works on multiple selections so unless your script does something extra I don't think it's needed.
Here's another quick question, what's the diference between "subdivDisplaySmoothness -smoothness 1;" and "subdivDisplaySmoothness -smoothness 0;"? Because there is no visual difference.
Something Maya does by default. Theres no real difference haha.
i haven't tried haiddasalami script, but if you're fine with it, use it.
i attached a picture with instructions on installing the script. there is no magic code in it, so it should work
Bal - Your little script, because with MEL you have to declare int, float etc, how did you justify that the variables $wires was going to be a string ?
I can't even get Bal script to work with a Y assigned hotkey, arghh.
What you can do to proive this:
- copy and paste the script into the script editor
- select everything and middle-mouse drag it to a shelf
- then you have clickable button(don't forget to select your object)
that shold work. or you can:
- select your object
- select the whole mel code in the script editor and press enter(num tab!) -> this also executes the code
if this works(i'm sure it will ) you can check your key assignment problem
Small script to set multiple objects selected the smoothing level (3 button) to a value of your choice.
// Warning: Line 3.34 : Redeclaration of variable "$sel" shadows previous declaration at line 1. Previous value will be overwritten by explicit initializer. //
The other issue is that it doesn't work for objects in component mode.
Wow, thanks!
God Bless you :D