[Maya MEL] Separate mesh by edges

mel
maya

#1

Hi everyone.

One week ago I found what my team spend a lot of time for reviewing UV and padding. So I decided to wrote script for Maya for checking padding. Main condition was - Maya LT, so I can use only MEL…

I solved the problem. In few words: calculate hypotenuse from Point C (vertex) to A and B points (edge vertices) using minimum padding (small cathetus CD) and compare (AD+DB) with real edge length (AB). And some simple (or not :wink: ) conditions, exceptions, inspections… And a lot of optimization, because at first time all worked great… but spent a a lot of time…
Also at begun I checked harden/soften edges+saved them in list, so at the end I assign them back.

And now problem:


if I have geometry something like that, cylinder, I detaching geometry by edges, and red edge remains un-cut on mesh and cut on UV. That would not be a problem if I didn’t need to use a cleanup to fix mesh errors and detached polygons to solve problem.
I can’t found solution, or scripts… It’s simple command in Max - split… but in Maya for me it is unreal problem.

*I used DetachComponent;

small GIF presents result, Pinned vertexes have small padding to near UV shell:


#2

You need to do the detach on the vertices not the edge.


#3

baaad idea :roll_eyes: the entire perimeter of geometry will turn into separate polygons


#4

You want to convert the edge that you’re operating on to vertices, and then detach just those vertices that make up the edge you are operating on.

polyListComponentConversion is helpful for this kind of thing.


#5

I tested next code with all exist flags-combinations:

string $detach_edg[];
$detach_edg = `polyListComponentConversion -fe -tv`;
    for ($vrt in $detach_edg)
        {
            DetachComponent;
        }

Result each time ± the same:

And I solved the problem. Result:

This situation with this mesh’s form is an exception, but this form exists so problem exists too.
And resulting code:

        SelectFacetMask;
        SelectAll;
        string $all_polys[];
        $all_polys = `ls -sl -fl`;
        string $current_polys[];
        
        for ($polys in $all_polys)
        {
            select $polys;
            polySelectBorderShell 0;
            DetachComponent; 
            $all_polys = stringArrayRemove(`ls -sl -fl`, $all_polys);
        }
        SelectAll;
        polyMergeUV -d 0.00001 -ch 1;           
        Edges_border();
        DetachComponent;

With this separation I can save the soften/harden edges on the object after running the script