Thanks a lot for everybodys help on this. The script works perfectly.
But now i run into another problem. First I must explain the purpose for requesting this script.
This is part of the main Script Im trying to write which is Quad fill (imitating Quad-cap max plugin by obliviboy). So far Ive been sampling many mel scripts to make this work since, I am a noob at mel. I know this is a complicated thing to do for a beginner.
Heres my Idea or concept for making the Quad Fill work. Feel free to comment and critique:
1)Get edge selection of the hole that needs to be filled
2)Create locators to store the xyz location of the vertices on the border. Which will later be used to snap the quad plane back to Main mesh.
This method might be too inefficient, but its the only way I can think of. Since I have no idea how to create a script that knows how to divide the Ngon into quads.
3)Test if the edges are even. reason being that solving quads need even edges.
global proc testEven ()
int $edgeNum = `polyEvaluate -edge`;
if ($edgeNum % 2 == 0)
4)checkEqualedge is to test if edges can be evenly distributed on 4 sides. Mainly is to store the Subdivisions of the width and height required to create the quad plane.
global proc checkEqualedge ()
int $fmodNum =`fmod($edgeNum,4)`
int $wholeNum =`$edgeNum / 4`
if ($fmodNum == 0)
$SubDH = $WholeNum //SubDH is Subdivision Height
$SubDW = $WholeNum ////SubDH is Subdivision Width
$SubDH = $roundNum + 1
$SubDW = $roundNum
5) Get the rotation axis of the edge selection.
The following code I found off of this site http://xyz2.net/mel/mel.005.htm
Not sure how to get this to work. always run into invalid syntax#
proc vector translatePolyInfoNormal( string $pin )
int $numTokens = `tokenize $pin " " $tokens`;
// Make sure we're looking at polyInfo data:
if ( ( $numTokens > 3 ) && ( $tokens == "FACE_NORMAL" ) )
// Maya performs data-type conversion here.
$x = ($tokens[$numTokens-3]);
$y = ($tokens[$numTokens-2]);
$z = ($tokens[$numTokens-1]);
$normal = << $x, $y, $z >>;
// Normalize it.
$normal = `unit $normal`;
// Return it.
string $FaceInfo = `polyInfo -fn pPlane6.f`;
vector $FaceNormal = translatePolyInfoNormal( $FaceInfo);
I need this code to get the values neccessary to move the Quad plane back to the original mesh that needed to be capped.
6)snap the border of the Quad plane to the Main Mesh with closestVerticeToLoc created by haiddasalami
7)Combine both Meshs and call it a day.
Hope this is not too confusing or long to read.