-- Geo-Cleaner -- Cleans the history from selected objects (helps to reduce Max file size) -- -- Dani Rosen - Aug 29, 2006 -- -- v1.1 - Aug 30, 2006 - MaterialID preservation added, backface culling preserved, selection sets preserved macroScript GeoCleaner category:"DaniTools" internalcategory:"DaniTools" tooltip:"Geo-Cleaner" buttontext:"Geo-Cleaner" Icon:#("SubObjectIcons",33) ( global cObj fn GeoFilter GF = ((superClassOf GF == GeometryClass) and (ClassOf GF != Targetobject)) rollout GeoCleaner "Geo-Cleaner v1.1" ( label lbObj "Please select the objects to be cleaned" height:25 button bObjects "Select Objects" width:120 checkbox bAnim "Preserve Object Animations" checked:false align:#center checkbox bProp "Retain Object Properties" checked:true align:#center label spacer "" height:10 button bClean "CLEAN" width:100 height:30 enabled:false label spacer2 "" height:3 progressBar cProgBar "Progress" height:7 label lProg "" pos:[130,172] button bAbout "?" tooltip:"About..." width:12 height:18 pos:[238,172] on bAbout pressed do ( rollout rolAbout "About" ( label ab1 "Geo-Cleaner v1.1" label ab2 "Dani Rosen \xa9 2006" progressBar horizLine "ProgressBar" height:3 enabled:true value:100 color:(color 10 10 0) label ab3 "This tool cleans the history from" label ab4 "selected geometry."height:20 label ab5 "Notes:" align:#left label ab6 "1. Processed objects will end up" align:#left label ab7 " with a collapsed stack." align:#left label ab8 "2. EditPoly or EditPatch will be" align:#left label ab9 " converted to EditMesh." align:#left ) createdialog rolAbout width:180 height:190 ) on bObjects pressed do ( cObj = selectByName title:"Pick Objects to Clean" showHidden:true single:false filter:GeoFilter if cObj == undefined then ( bObjects.text = "Select Objects" bClean.enabled = false lProg.text = "" return 0 ) else ( if cObj.count > 1 then ( bObjects.text = "Multiple Selected" bClean.enabled = true lProg.text = "" ) else ( bObjects.text = cObj[1].name bClean.enabled = true lProg.text = "" ) ) ) on bClean pressed do ( lProg.text = "working..." global ObjNum = cObj.count for i in 1 to cObj.count do ( objName = cObj[i].name if bProp.checked == true then ( -- properties: objXray = cObj[i].xray objIgnoreExtents = cObj[i].ignoreExtents objBoxMode = cObj[i].boxMode objAllEdges = cObj[i].allEdges objBackFaceCull = cObj[i].backFaceCull objWireColor = cObj[i].wireColor objShowLinks = cObj[i].showLinks objShowLinksOnly = cObj[i].showLinksOnly objShowTrajectory = cObj[i].showTrajectory objShowVertexColors = cObj[i].showVertexColors objCastShadows = cObj[i].castShadows objReceiveShadows = cObj[i].receiveShadows objVisibility = cObj[i].visibility objInheritVisibility = cObj[i].inheritVisibility objRenderable = cObj[i].renderable objRenderOccluded = cObj[i].renderOccluded objMotionBlurOn = cObj[i].motionBlurOn objRcvCaustics = cObj[i].rcvcaustics objGenerateCaustics = cObj[i].generatecaustics objRcvGlobalIllum = cObj[i].rcvGlobalIllum objGenerateGlobalIllum = cObj[i].generateGlobalIllum -- selection sets: global cObjSelSets = #() for s in 1 to selectionsets.count do ( for t in selectionsets[s] do ( if cObj[i] == t then append cObjSelSets (getNamedSelSetName s) ) ) ) -- processing TempSphere = sphere name:"#TempSphere" radius:10 smooth:on segs:10 ConvertToMesh TempSphere if bAnim.checked == true then ( TempSphere.transform.controller = cObj[i].transform.controller ) else ( TempSphere.transform = cObj[i].transform ) if classof cObj[i].material == Multimaterial then ( TempSphere.material = cObj[i].material[cObj[i].material.count] ) else ( TempSphere.material = cObj[i].material ) attach TempSphere cObj[i] meshop.deleteFaces TempSphere #{1..80} delIsoVerts:true if bProp.checked == true then ( -- properties TempSphere.xray = objXray TempSphere.ignoreExtents = objIgnoreExtents TempSphere.boxMode = objBoxMode TempSphere.allEdges = objAllEdges TempSphere.backFaceCull = objBackFaceCull TempSphere.wireColor = objWireColor TempSphere.showLinks = objShowLinks TempSphere.showLinksOnly = objShowLinksOnly TempSphere.showTrajectory = objShowTrajectory TempSphere.showVertexColors = objShowVertexColors TempSphere.castShadows = objCastShadows TempSphere.receiveShadows = objReceiveShadows TempSphere.visibility = objVisibility TempSphere.inheritVisibility = objInheritVisibility TempSphere.renderable = objRenderable TempSphere.renderOccluded = objRenderOccluded TempSphere.motionBlurOn = objMotionBlurOn TempSphere.rcvcaustics = objRcvCaustics TempSphere.generatecaustics = objGenerateCaustics TempSphere.rcvGlobalIllum = objRcvGlobalIllum TempSphere.generateGlobalIllum = objGenerateGlobalIllum -- selection sets: if cObjSelSets.count != 0 then ( for u in 1 to cObjSelSets.count do ( global currentSet = #() for k in selectionsets[cObjSelSets[u]] do append currentSet k append currentSet TempSphere selectionsets[cObjSelSets[u]] = currentSet ) ) ) TempSphere.name = objName cProgBar.value = 100.0*i/ObjNum redrawviews() ) lProg.text = "Done!" bClean.enabled = false ) ) createdialog GeoCleaner 250 190 )