--DDF34.MS - R3 compatible --This short free Utility checks for Double Faces in Meshes. --It is a fix for the bug in STL-Check Modifier which --selects both faces in a pair of Double Faces. ------------------------------------------------------------------------------------------------ --THIS REVISION adds explicit check for MAX 2 / MAX 3 version and --implements version-specific code depending on the version. ------------------------------------------------------------------------------------------------ --You may use, redistribute and modify this utility freely. --Please give me credit if you do so. --For questions and sugestions, email me at --bobo@email.archlab.tuwien.ac.at --or visit Boboland: --http://gfxcentral.com/bobo/ ------------------------------------------------------------------------------------------------- --DISCLAIMER: This utility modifies your meshes! Use it at your own risk! --And save (or at least Hold) frequently... utility delete_double_faces "DDF" ( local del_array =#() group "About..." ( label ddfabout01 "DeleteDoubleFaces" label ddfabout02 "Version 3.4 - 8/10/2000" label ddfabout03 "(c)Bobo's Rendert**ls" label ddfabout04 "http://gfxcentral.com/bobo/" ) group "DoubleFace Check" ( button scan_faces "CHECK Selected Meshes" width:140 height:30 checkbox q_check "Quick Check" checked:true checkbutton extract_faces "EXTRACT DoubleFaces" width:140 checked:false highlightcolor:([128,255,128] as color) checkbutton remove_faces "DELETE DoubleFaces" width:140 checked:false highlightcolor:([255,128,128] as color) radiobuttons remove_kind "Deletion Method:" labels:#("Add DeleteMesh Modifier","Collapse EMeshes only","Collapse All Meshes") ) fn scan_for_double_faces c_node = ( e_node = c_node txt = ("Checking Mesh "+ e_node.name) format "%\n" txt ms = mesh_select () addmodifier e_node ms total_faces = e_node.numfaces txt = total_faces as string + " Faces in Mesh." format "%\n" txt face_array = #() del_array = #() progressStart "DoubleFaces Check:" for i = 1 to e_node.numfaces do ( progress_percent = (i as float / e_node.numfaces )*100 if old_percent != progress_percent then ( old_percent = progress_percent not_user_cancel = progressUpdate progress_percent if not not_user_cancel then exit ) get_face = getface e_node i if not q_check.checked then ( dd_found = false for j = 1 to face_array.count do ( if face_array[j] == get_face then ( append del_array i dd_found = true ) if face_array[j].x == get_face.y and (face_array[j].y == get_face.x) and (face_array[j].z == get_face.z ) then ( append del_array i dd_found = true ) if face_array[j].x == get_face.z and (face_array[j].y == get_face.y) and (face_array[j].z == get_face.x ) then ( append del_array i dd_found = true ) if face_array[j].x == get_face.x and (face_array[j].y == get_face.z) and (face_array[j].z == get_face.y ) then ( append del_array i dd_found = true ) if face_array[j].x == get_face.y and (face_array[j].y == get_face.z) and (face_array[j].z == get_face.x ) then ( append del_array i dd_found = true ) if face_array[j].x == get_face.z and (face_array[j].y == get_face.x) and (face_array[j].z == get_face.y ) then ( append del_array i dd_found = true ) ) if not dd_found then append face_array get_face ) else ( f_item = findItem face_array get_face if f_item != 0 then ( append del_array i ) else ( append face_array get_face ) )--end q_check )--end i loop progressEnd () if del_array.count > 0 then ( txt = del_array.count as string + " DoubleFaces Found!" format "%\n" txt delete_enabled = true ) else ( txt = "No DoubleFaces Found!" format "%\n" txt delete_enabled = false ) deletemodifier e_node ms delete_enabled )--end check fn fn remove_double_faces c_node = ( e_node = c_node undo on ( ms = mesh_select () dm = deletemesh () -- if not max_3 then -- ( -- addmodifier e_node ms -- setfaceselection e_node ms del_array -- addmodifier e_node dm -- ) -- else ( max modify mode modPanel.addModToSelection ms subObjectLevel = 3 setfaceselection e_node ms del_array modPanel.addModToSelection dm max utility mode ) txt = del_array.count as string + " Faces Selected..." format "%\n" txt txt = "DeleteMesh Modifier Applied." format "%\n" txt if remove_kind.state == 2 then ( n_mods = e_node.modifiers.count if n_mods == 2 then ( collapsestack e_node txt = "Modifier Stack Collapsed." format "%\n" txt ) else ( txt = "No Changes To Modifier Stack." format "%\n" txt ) ) if remove_kind.state == 3 then ( collapsestack e_node txt = "Modifier Stack Collapsed." format "%\n" txt ) )--end undo )--end on fn extract_double_faces c_node = ( e_node = c_node undo on ( select e_node ms = mesh_select () addmodifier e_node ms new_vert_array = #() new_face_array = #() new_mat_ids = #() new_t_verts = #() for i = 1 to e_node.numverts do ( new_vert_array[i] = getvert e_node i ) for i = 1 to del_array.count do ( append new_face_array (getface e_node del_array[i]) append new_mat_ids (getfacematid e_node del_array[i]) ) new_node = mesh vertices:new_vert_array faces:new_face_array materialids:new_mat_ids --tverts:new_t_verts new_tvc= getNumTVerts e_node setnumTVerts new_node new_tvc if new_tvc > 0 then ( for i = 1 to e_node.numtverts do ( settvert new_node i (gettvert e_node i) ) buildTVfaces new_node ) --SET TVFACES, EDGE VISIBILITY AND SMOOTHING GROUPS for i = 1 to del_array.count do ( if new_tvc > 0 then ( new_tvface = (getTVface e_node del_array[i]) setTVface new_node i new_tvface ) new_edgevis_1 = (getedgevis e_node del_array[i] 1) new_edgevis_2 = (getedgevis e_node del_array[i] 2) new_edgevis_3 = (getedgevis e_node del_array[i] 3) new_smooth = (getfacesmoothgroup e_node del_array[i]) setedgevis new_node i 1 new_edgevis_1 setedgevis new_node i 2 new_edgevis_2 setedgevis new_node i 3 new_edgevis_3 setfacesmoothgroup new_node i new_smooth ) update new_node deletemodifier e_node ms new_node.name = ("DF_"+ e_node.name) if e_node.material != undefined then new_node.material = e_node.material new_node.pivot = e_node.pivot txt = "DoubleFaces Extracted to EMesh " + new_node.name format "%\n" txt )--end undo )--end on on scan_faces pressed do ( obj_array = selection as array for n = 1 to obj_array.count do ( check_node = obj_array[n] select check_node if classof check_node == Editable_Mesh then ( scan_result = scan_for_double_faces check_node if scan_result then ( if extract_faces.checked then extract_double_faces check_node if remove_faces.checked then remove_double_faces check_node ) ) )--end n loop txt = "Ready." format "%\n" txt format "\n" select obj_array ) on delete_double_faces open do ( max_3 = true try(MaxVersion())catch(max_3 = false) if max_3 then format "MAX 3 or higher Detected.\n" else format "MAX 2 Detected.\n" ) )--end util