So I'm starting to get into MEL script, spent about 20 minutes tonight trying to make this script, and for the most part it was a success, and actually easier than I thought it would be, which is nice.
Script overview:
For any arbitrary object, find any UV border edges, and make those all Hard Edges, while leaving all other interior edges as Soft Edges.
It works 99% of the time, but will not work on UV shells which only have border verts, since the way Maya converts UV verts to edges means that it will select ALL edges attached to each selected UV vert, rather than just edges shared by selected UVs.
People keep telling me how flexible and awesome MEL script is, so now's the time to show me
Here's an image demonstrating the problem, and the solution I'd like to reach:
You'll notice that the UV shell highlighted on the left does not get its interior edges softened, because they are all attached to UV border verts. The other UV shells all work out correctly.
The lower part of the image shows what I want to achieve (basically just making the edges highlighted in red soft like the other interior edges).
Here's what the script does so far (yes, I'm aware it could probably be optimised a bit, this is my first MEL script ever, so go easy on me!
)
<font class="small">Code:</font><hr /><pre>changeSelectMode -object;
string $objList[] = `ls -sl`;
for ($subObj in $objList) {
select -r $subObj;
polyNormalPerVertex -ufn true;
polySoftEdge -a 0 -ch 1 $subObj;
select -r $subObj.map["*"];
polySelectBorderShell 1;
textureWindowSelectConvert 2;
PolySelectTraverse 2;
invertSelection;
polySoftEdge -a 180 -ch 1;
}
select -r $objList;</pre><hr />
Basically it's just stepping through what I'd do if I was going to do this manually, so it's probably possible to condense this down to just one or two lines instead of this many, but I haven't got around to that yet.
Here is an OBJ file of my simple test object, if any MEL gurus here would like to have a crack at this problem...
http://www.greveson.co.uk/dump/script_test_object.obj
Any help or advice would be much appreciated. It will be good if it's just a flag or option somewhere that I have missed...
Replies
That's the solution I had in the back of my head but I was wondering if there might be a more simple way (a command or option I'd missed maybe). Fair enough!
I tried running this script and all i get is a syntax error, is there a special way i need to run this or something like that?
Replace it with > , the greater than sign.
8th line from the bottom, should look like this: Edit: wtf - every time i try to post this the boards go batshit...
Edit2: inside the size( ) is meant to be $edgeUVs, I have no idea why it's stripping it out... PHP?
if( size( $edgeUVs ) > 2 ) {
http://dl.dropbox.com/u/499159/UVShellHardEdge.mel
// Warning: Some items cannot be moved in the 3D view. // // Warning: Some items cannot be moved in the 3D view. //
// Warning: Some items cannot be moved in the 3D view. //
anyone know why?
those are just warnings, not errors, so the script very well could still be working as expected.
since i personally use python version that does Exactly what this script does and it all works great for me.
though like i said, it takes almost the same approach as the mel one so the issue you got is prolly elsewhere.
As for your black edges, you probably have one of two situations:
1) Try unlocking your normals (in the Normals menu) and then running the script.
2) You have edges that are > 90 degrees that are soft and they are getting really poor lighting. In this case, and I'm assuming you're baking normals, that edge should be a UV boundary and made hard.
If those don't fix it, post a pic.
Thanks so much guys!
But I can only get the script to work if I manually load and execute it via the script editor. When I try and call it via the MEL command line I get:
// Error: Cannot find procedure "UVShellHardEdge".
Any idea what I'm doing wrong? Or is that just the way this script is setup.
Sorry if this is a noob question. I'm pretty new to running scripts inside of Maya.
a long time
Script should be added to the Wiki - thanks for the thread
run it with your objects selected.
finalBorder [ len( finalBorder ) ] = curEdge
# Error: line 1: IndexError: file <maya console> line 20: list assignment index out of range #
Here is the code so far:
any help would be greatly appreciated.
obviously that didn't work... thanks for the help, it is much appreciated.
also, it looks like I don't need the fist finalBorder = [] anymore.
holy moly this is old
Cheers!
Thanks for both script! Save me a lot of time
This: http://jonathonstewart.blogspot.com/2012/10/script-harden-edges-of-all-uv-borders.html