max modify mode rollout FlattenUvs "Flatten Uvs" width:175 height:327 ( label 'Credits' "Version: 0.1 \n By: Juan Camilo Alcaraz \n www.camiloalcaraz.com" pos:[24,264] width:125 height:47 align:#left button 'Start_Flatten' "Start Flatten Uvs" pos:[33,146] width:110 height:49 align:#left GroupBox 'title' "Flatten Uvs" pos:[12,14] width:151 height:199 align:#left checkbox 'Flattenchkbtn' "Collapse" pos:[35,106] width:107 height:17 align:#left checkbox 'saveonend' "Save on End" pos:[35,126] width:107 height:17 align:#left spinner 'FlatValue' "F.Value " pos:[32,45] width:61 height:16 range:[0,180,50] type:#integer scale:0.1 align:#left label 'ProgressText' "Progress: 0%" pos:[20,218] width:140 height:24 align:#left spinner 'MapChannel' "Map Channel" pos:[33,71] width:60 height:16 type:#integer scale:1 align:#left range:[1,3,1] on Start_Flatten pressed do ( seleccion = for i in selection where superclassof i == geometryclass collect i if seleccion.count != 0 then ( for i = 1 to seleccion.count do ( windows.processPostedMessages() --avoid script freezes select seleccion[i] Sel = getpolygoncount seleccion[i] max modify mode addmodifier seleccion[i] (Vertex_Weld ()) seleccion[i].modifiers[#Vertex_Weld].threshold = 0.001 addmodifier seleccion[i] (Smooth()) seleccion[i].modifiers[ #Smooth].autosmooth = on PSel = Sel[1] SelArray = for o = 1 to Psel collect o UvArray = SelArray as bitarray addmodifier seleccion[i] (UVW_Mapping_Clear ()) seleccion[i].UVW_Mapping_Clear.mapID = FlattenUvs.MapChannel.value addmodifier seleccion[i] (Unwrap_UVW ()) seleccion[i].Unwrap_UVW.setMapChannel FlattenUvs.MapChannel.value seleccion[i].unwrap_uvw.selectPolygons UvArray --Flatten Mapping seleccion[i].Unwrap_UvW.flattenMap FlatValue.value #() 0.005 true 0 true true --i.Unwrap_UVW.flattenMapNoParams() -- Pack seleccion[i].unwrap_UVW.pack 2 0.001 true true true subobjectLevel = 0 clearselection() if flattenchkbtn.state == true do ( converttopoly seleccion[i] ) FlattenUvs.ProgressText.text = "Progress: " + ((i * 100 / seleccion.count) as string) + "%" + " / " + (i as string) + " of " + (seleccion.count as string) if ( FlattenUvs.saveonend.state == true) do ( if seleccion.count > 10 do ( if i == seleccion.count/4 do (saveMaxFile (maxFilePath + maxfilename)) if i == seleccion.count/2 do (saveMaxFile (maxFilePath + maxfilename)) if i == ((seleccion.count * 75)/100) do (saveMaxFile (maxFilePath + maxfilename)) ) ) gc() ) FlattenUvs.ProgressText.text = "Progress: 0%" if ( FlattenUvs.saveonend.state == true) do ( saveMaxFile (maxFilePath + maxfilename) ) messagebox "Progress End" ) else ( messagebox "Select an object to Flatten the uvs" ) ) ) createdialog FlattenUvs width: FlattenUvs.width height: FlattenUvs.height