Although I have experience in C++ but I am new to MEL and I have problems with alot of MEL syntax. Basically, I wanted to create a MEL to perform some simple selection of vertices base on their positions.
Say I need to select all vertices that are on the Yaxis (with the vertices X value=0 +-tolerance). This is what I have written, it doesn't work, of course, due to my lack of knowledge of some syntax:
for ( $i=0; $i<=LASTVERTEXNUMBER; $i++) { if (objectname.vtx[i[]] XVALUE>= $min_tolerance)&& (objectname.vtx[i[]] XVALUE><= $max_tolerance)then { select -tgl objectname.vtx[i[]]; } } I need the actual syntax of the bolded word.
Q1)How to determine the last vertex number? Q2) What is the syntax to get the absolute (or world coordinate) value of its X, Y and Z coordinates? ( I can query the value using "xform -q -ws -t objectname.vtx but I don't know how to use in an expression like a=b;)
I did something similar in my mirror script. I wanted to soften the seam after merging verts, but only along the yz axis. I posted the code to do it below. Also note that I'm using Bryan Ewerts round off procedure (modified by Duncan Brinsmead) to handle weird "0" float values (e.g. -8.881784329e-017).
there is a proc inside it called locateVertex which takes inputs of "XYZ position", "XYZ range" and "tolerance" and selects any verts it finds there. you should be able to get what you want from this, and there is a bit of debug comments and prints in the script.
Thanks guys. Got to pick up MEL seriously one of these days. This is my 2nd month using MAYA, and there are still got alot of stuff to learn (let alone master).