Max xview uv seams

(
    global UvSeamChecker

    struct UvSeamCheckerStruct (

        channel = 1,
        dialog = undefined,
        facen = 1,
        edges = #(),

        fn geomCheck theTime node result = (
            local t = timestamp()
            local fan = node.faces.count
            if (UvSeamChecker.facen == fan) then ()--do nothing
            else (
                UvSeamChecker.facen = node.faces.count
                local mesh = snapshotasmesh node
                local edges = #()
                local verts = #()
                
                if meshop.getmapsupport mesh channel do  (
                    print(channel)
                    numtverts = meshop.getnummapverts mesh channel
                    getmapface = meshop.getmapface
                    
                    tfaces = for f=1 to mesh.numfaces collect (getmapface mesh channel f)
                    
                    local emesh = TriMesh()
                    setmesh emesh numverts:numtverts numfaces:mesh.numfaces
                    setmesh emesh faces:tfaces

                    seamed = meshop.getopenedges emesh 
                    opened = meshop.getopenedges mesh * seamed
                    faces = meshop.getfacesusingedge mesh seamed
                    for f in faces do (
                        local vv = getface mesh f
                        e = f*3 - 3
                        
                        if seamed[e += 1] and (vv[1] < vv[2] or opened[e]) do append verts #(int vv.x, int vv.y)     -- get the indices of the vertices only
                        if seamed[e += 1] and (vv[2] < vv[3] or opened[e]) do append verts #(int vv.y, int vv.z)
                        if seamed[e += 1] and (vv[3] < vv[1] or opened[e]) do append verts #(int vv.x, int vv.z)
                        
                    )
                    
                    
                )
                fn difx a b = (
                    arr = #()
                    for e in a do (
                        idx = finditem b e
                        if idx == 0 then
                        append arr e
                    )
                    return arr
                )
                local getVertEdges = polyop.getEdgesUsingVert
                /**local seamverts = join (for v in verts collect v[1]) (for v in verts collect v[2])
                print("1:" + (timestamp() - t) as string)
                local allfaces = node.faces
                print("2:" + (timestamp() - t) as string)
                local allvertex = for v in node.verts collect v.index--polyop.getVertsUsingFace node allfaces
                print("3:" + (timestamp() - t) as string)
                local alledges  = for e in node.edges collect e.index --polyop.getEdgesUsingFace node allfaces
                print("4:" + (timestamp() - t) as string)
                local iv = (allvertex as bitarray - seamverts as bitarray)as array --difx allvertex seamverts 
                print("5:" + (timestamp() - t) as string)
                local ie = polyop.getEdgesUsingVert node iv
                print("6:" + (timestamp() - t) as string)
                edges = difx alledges ie
                print("7:" + (timestamp() - t) as string)
                --
                **/
                --for v in verts do join edges ((getVertEdges node v[1]) * (getVertEdges node v[2])) --get edge between two verts
                for i = 1 to verts.count do append edges (((getVertEdges node verts[i][1]) * (getVertEdges node verts[i][2]))as array)[1]
                free mesh
                free emesh
                UvSeamChecker.edges = edges
            )
            join result UvSeamChecker.edges
            2
        ),
     
        fn supportedCheck node = (classof node == Editable_Poly or classof node == PolyMeshObject),
        
        fn configDialog = (
            try(destroyDialog UvSeamChecker.dialog)catch()
            rollout config "Config" (
                spinner channelspinner "UV Channel:" range:[1,1000000,UvSeamChecker.channel] type:#integer
                on channelspinner changed value do (
                    UvSeamChecker.channel = value
                    XViewChecker.runCheck CurrentTime
                    max views redraw
                )   
            )
            createDialog config
            setDialogPos config mouse.screenpos
            UvSeamChecker.dialog = config
        ),
        
        fn textOverride = (xViewChecker.getCurrentOutputCount() as string ),
        fn dispOverride theTime theNode theHwnd theResults = (
          local theColor = red
          XViewChecker.displayResults theColor theTime theNode theHwnd #Edges theResults
        )
    )
     
    try(destroyDialog UvSeamChecker.UvSeamCheckerDialog)catch()
    UvSeamChecker = UvSeamCheckerStruct()
     
    XViewChecker.unRegisterChecker "Uv Seams"
    XViewChecker.registerChecker UvSeamChecker.geomCheck UvSeamChecker.supportedCheck #Edges "Uv Seams" UvSeamChecker.configDialog UvSeamChecker.textOverride undefined --UvSeamChecker.dispOverride
)