macroScript SelectArea category:"Piranha-Bytes" buttonText:"SelectArea" toolTip:"Select Faces by Area" ( rollout ro_SelectArea "pb Select Area" ( pickbutton ui_SA_Obj "Pick Object" pos:[5,5] width:100 height:20 tooltip:"Pick Object" spinner ui_SA_Area "Area: " pos:[5,30] range:[0,100,100] fieldWidth:40 scale:0.1 type:#float checkButton ui_SA_AreaType "A" pos:[89,30] width:16 height:16 tooltip:"A = Average Area Size, B = Biggest Area Size" checkButton ui_SA_Less "<" pos:[5,55] width:20 height:20 checked:true tooltip:"Select faces with SMALLER area" checkButton ui_SA_Equal "=" pos:[25,55] width:20 height:20 checked:false tooltip:"Select faces with EQUAL area" checkButton ui_SA_More ">" pos:[45,55] width:20 height:20 checked:false tooltip:"Select faces with GREATER area" button ui_SA_Verts "Verts" pos:[70,55] width:35 height:20 tooltip:"Convert Faceselection to Vertexselection" local theObj = undefined local avgArea = 0 local biggestArea = 0 function updateAreaSelection = ( if theObj != undefined do ( if ((getCurrentSelection())[1] != theObj) then select theObj if (subObjectLevel != 4) then subobjectLevel = 4 if ui_SA_AreaType.state == false then theArea = avgArea * (ui_SA_Area.value / 100.0) if ui_SA_AreaType.state == true then theArea = biggestArea * (ui_SA_Area.value / 100.0) selMode = 0 if ui_SA_Less.state == true then selMode = 1 if ui_SA_Equal.state == true then selMode = 2 if ui_SA_More.state == true then selMode = 3 faceCount = theObj.faces.count newFaces = #() for f = 1 to faceCount do ( a = (polyOp.getFaceArea theObj f) if ((selMode == 1) and (a < theArea)) then append newFaces f if ((selMode == 2) and (a == theArea)) then append newFaces f if ((selMode == 3) and (a > theArea)) then append newFaces f ) polyOp.setFaceSelection theObj newFaces forceCompleteRedraw() ) ) function init_Obj = ( faceCount = theObj.faces.count aa = 0 areaList = #() for f = 1 to faceCount do ( a = (polyOp.getFaceArea theObj f) append areaList a aa = aa + a ) avgArea = aa / (faceCount as float) biggestArea = amax areaList ui_SA_Area.value = 100 select theObj subObjectLevel = 4 updateAreaSelection() ) on ro_SelectArea open do ( curObj = (getCurrentSelection())[1] if curObj != undefined do ( objBase = (classof curObj.baseobject) as string if (objBase == "Editable_Poly") do ( theObj = curObj ui_SA_Obj.caption = theObj.name init_Obj() ) ) ) on ui_SA_AreaType changed state do ( if state == true then ui_SA_AreaType.caption = "B" if state == false then ui_SA_AreaType.caption = "A" updateAreaSelection() ) on ui_SA_Obj picked obj do ( objBase = (classof obj.baseobject) as string if (objBase == "Editable_Poly") then ( theObj = Obj ui_SA_Obj.caption = theObj.name init_Obj() ) else messageBox "No Editable Poly !!!" ) on ui_SA_Area changed val do updateAreaSelection() on ui_SA_Less changed state do ( ui_SA_Less.state = true ui_SA_Equal.state = false ui_SA_More.state = false updateAreaSelection() ) on ui_SA_Equal changed state do ( ui_SA_Less.state = false ui_SA_Equal.state = true ui_SA_More.state = false updateAreaSelection() ) on ui_SA_More changed state do ( ui_SA_Less.state = false ui_SA_Equal.state = false ui_SA_More.state = true updateAreaSelection() ) on ui_SA_Verts pressed do ( if theObj != undefined do ( theObj.convertSelection #Face #Vertex subObjectLEvel = 1 ) ) ) createDialog ro_SelectArea width:110 style:#(#style_sysmenu, #style_Toolwindow) )