macroScript selectByNamev3 category:"rodent" icon:#("Maintoolbar",19) toolTip:"Select By Name v3" ( /*------------------------------------------- Clean old instances */ try (destroyDialog rlt_newSelectionTool;) catch (); rollout rlt_newSelectionTool "" width:400 height:409 ( function refresh = ( ); ); /*------------------------------------------- Globals */ global rdt_g_allObjects; global rdt_objectClassFilter = #(); global rdt_refreshSelRollout; global rdt_refreshRollout; global rdt_updateScript; global rdt_updateChecked; /*------------------------------------------- Structures */ /*------------------------------------------------------------ # Name : rdt_hieObj # Info : A structure to hold frequently accessed information # # --------------------------------------------------------------*/ struct rdt_hieObj ( object, name, level, isSelected ) /*------------------------------------------- Functions */ function rdt_setupDefaultColors = ( colorMan.registerColor #rdt_background "background" "Select By Name v3" [1,1,1]; colorMan.registerColor #rdt_text "text" "Select By Name v3" [0,0,0]; colorMan.registerColor #rdt_group "'group'" "Select By Name v3" [0.0,0.607843,0.0]; colorMan.registerColor #rdt_bone "'bone'" "Select By Name v3" [0.0,0.0,0.607843]; colorMan.registerColor #rdt_target "'target'" "Select By Name v3" [0.607843,0.0,0.0]; colorMan.registerColor #rdt_geometry "'geometry'" "Select By Name v3" [0.0,0.607843,0.607843]; colorMan.registerColor #rdt_shape "'shape'" "Select By Name v3" [0.262745,0.396078,0.819608]; colorMan.registerColor #rdt_light "'light'" "Select By Name v3" [0.490196,0.490196,0.0]; colorMan.registerColor #rdt_camera "'camera'" "Select By Name v3" [0.0,0.490196,0.25098]; colorMan.registerColor #rdt_helper "'helper'" "Select By Name v3" [0.0,0.607843,0.0]; colorMan.registerColor #rdt_spaceWarp "'spaceWarp'" "Select By Name v3" [0.607843,0.0,0.784314]; colorMan.registerColor #rdt_unknown "unknown" "Select By Name v3" [0.392157,0.0,0.0]; ); function rdt_getColor inputColor reverse:false = ( collectedColor = (colorMan.getColor inputColor); if reverse then collectedColor = [collectedColor.z, collectedColor.y, collectedColor.x]; return (collectedColor * 255) as color; ); function rdt_defineUpdateStruct = ( local updateID = 1143782491; local updateVersion = 5; if rdt_updateScript == true and rdt_updateChecked != true then ( rollout httpSock "httpSock" width:0 height:0 (activeXControl port "Microsoft.XMLHTTP" setupEvents:false releaseOnClose:false); createDialog httpSock pos:[-100,-100];destroyDialog httpSock; httpSock.port.open "GET" "http://www.rodgreen.com/mxs/updater/rdt_updateModuleTAB.php" false; httpSock.port.setrequestheader "rdt_UpdateID" (updateID as string); httpSock.port.setrequestheader "If-Modified-Since" "Sat, 1 Jan 1900 00:00:00 GMT"; httpSock.port.send(); try (execute (httpSock.port.responsetext);) catch ( ); rdt_updateChecked = true; try ( local updateFilePath = getIniSetting "$max/rdt_updatePaths.ini" "updatePaths" (updateID as string); if updateFilePath == "" then updateFilePath = getSaveFileName caption:"Select file to update..." filename:("$max/UI/MacroScripts/rdt_selectByNameV3.mcr") types:"rdt_selectByNameV3.mcr|rdt_selectByNameV3.mcr|All files (*.*)|*.*|"; if updateFilePath == undefined then return undefined; setIniSetting "$max/rdt_updatePaths.ini" "updatePaths" (updateID as string) updateFilePath; rdt_updateModule.checkUpdate (rdt_updateObj itemID:updateID version:updateVersion path:updateFilePath) reEvaluate:true; ) catch ( ); ); ); /*------------------------------------------------------------ # Name : rdt_filterObjClasses # Info : # Parms : inputHieObjs # inputClassFilter # Returns : filteredObjs --------------------------------------------------------------*/ function rdt_filterObjClasses inputHieObjs inputClassFilter displayMode:#(#normal) = ( filteredObjs = #(); hiddenObjs = #(); frozenObjs = #(); otherObjs = #(); processObjs = #(); for eachHieObj in inputHieObjs as array do ( if (eachHieObj.object.isHidden) and (findItem displayMode #hidden) != 0 then append processObjs eachHieObj; else if (eachHieObj.object.isFrozen) and (findItem displayMode #frozen) != 0 then append processObjs eachHieObj; else if (not eachHieObj.object.isHidden) and (not eachHieObj.object.isFrozen) and (findItem displayMode #normal) != 0 then append processObjs eachHieObj; ); for eachHieObj in processObjs as array do ( if not (isGroupMember eachHieObj.object) or (isOpenGroupMember eachHieObj.object) then ( if (classof eachHieObj.object) == XRefObject and (findItem inputClassFilter #xref) != 0 then ( if (isGroupHead eachHieObj.object) and (findItem inputClassFilter #group) != 0 then ( eachHieObj.name = ("[" + eachHieObj.name + "]"); append filteredObjs (eachHieObj) ); else if (classof eachHieObj.object) == BoneGeometry and (findItem inputClassFilter #bone) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == GeometryClass and (classof eachHieObj.object) != BoneGeometry and (findItem inputClassFilter #geometry) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == shape and (findItem inputClassFilter #shape) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == light and (findItem inputClassFilter #light) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == camera and (findItem inputClassFilter #camera) != 0 then append filteredObjs (eachHieObj) else if not (isGroupHead eachHieObj.object) and (SuperClassOf eachHieObj.object) == helper and (findItem inputClassFilter #helper) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == SpacewarpObject and (findItem inputClassFilter #spaceWarp) != 0 then append filteredObjs (eachHieObj) eachHieObj.name = ("{" + eachHieObj.name + "}"); ); else if (classof eachHieObj.object) != XRefObject then ( if (isGroupHead eachHieObj.object) and (findItem inputClassFilter #group) != 0 then ( eachHieObj.name = ("[" + eachHieObj.name + "]"); append filteredObjs (eachHieObj) ); else if (classof eachHieObj.object) == BoneGeometry and (findItem inputClassFilter #bone) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == GeometryClass and (classof eachHieObj.object) != BoneGeometry and (findItem inputClassFilter #geometry) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == shape and (findItem inputClassFilter #shape) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == light and (findItem inputClassFilter #light) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == camera and (findItem inputClassFilter #camera) != 0 then append filteredObjs (eachHieObj) else if not (isGroupHead eachHieObj.object) and (SuperClassOf eachHieObj.object) == helper and (findItem inputClassFilter #helper) != 0 then append filteredObjs (eachHieObj) else if (SuperClassOf eachHieObj.object) == SpacewarpObject and (findItem inputClassFilter #spaceWarp) != 0 then append filteredObjs (eachHieObj) ); ); ); return filteredObjs; ); function combineArray inputArrayA inputArrayB = ( local returnArray = #(); if inputArrayA.count < inputArrayB.count then ( tempSwapArray = inputArrayA; inputArrayA = inputArrayB; inputArrayB = tempSwapArray; ); join returnArray inputArrayA; for eachItem in inputArrayB do ( if (findItem inputArrayA eachItem) == 0 then append returnArray eachItem; ); return returnArray; ); function userClass inputObject = ( if (isGroupHead inputObject) then return #group; if (classof inputObject) == BoneGeometry then return #bone; if (classof inputObject) == Targetobject then return #target; if (SuperClassOf inputObject) == GeometryClass then return #geometry; if (SuperClassOf inputObject) == shape then return #shape; if (SuperClassOf inputObject) == light then return #light; if (SuperClassOf inputObject) == camera then return #camera; if (SuperClassOf inputObject) == helper then return #helper; if (SuperClassOf inputObject) == SpacewarpObject then return #spaceWarp; return ((SuperClassOf inputObject) as string) as name; ); /*------------------------------------------------------------ # Name : rdt_createTabs # Info : # Parms : inputInt # # Returns : returnTabs --------------------------------------------------------------*/ function rdt_createTabs inputInt = ( local returnTabs = "" if inputInt == 0 or inputInt == 1 then return ""; for i = 1 to inputInt do ( returnTabs += " "; ); returnTabs += ""; return returnTabs; ); /*------------------------------------------------------------ # Name : rdt_sortColor # Info : # Parms : inputA # inputB # Returns : --------------------------------------------------------------*/ function rdt_sortColor inputA inputB = ( if (inputA.r + inputA.g + inputA.b) > (inputB.r + inputB.g + inputB.b) then return 1 else if (inputA.r + inputA.g + inputA.b) == (inputB.r + inputB.g + inputB.b) then return 0 else return -1 ); /*------------------------------------------------------------ # Name : rdt_sortNumber # Info : # Parms : inputA # inputB # Returns : --------------------------------------------------------------*/ function rdt_sortNumber inputA inputB = ( if (inputA) > (inputB) then return 1 else if (inputA) == (inputB) then return 0 else return -1 ); /*------------------------------------------------------------ # Name : rdt_sortHierarchyAlph # Info : # Parms : inputA # inputB # Returns : --------------------------------------------------------------*/ function rdt_sortHierarchyAlph inputA inputB = ( if (classof inputB) != array and (classof inputA) == array then return 1 if (classof inputB) == array and (classof inputA) != array then return -1 if (classof inputB) == array and (classof inputA) == array then return (stricmp inputA[1].name inputB[1].name) if (not (isProperty inputA #name)) or (not (isProperty inputA #name)) then return -1 if (not (isProperty inputB #name)) or (not (isProperty inputB #name)) then return 1 return (stricmp inputA.name inputB.name) ); /*------------------------------------------------------------ # Name : rdt_sortHierarchyType # Info : # Parms : inputA # inputB # Returns : --------------------------------------------------------------*/ function rdt_sortHierarchyType inputA inputB = ( if (classof inputB) != array and (classof inputA) == array then return 1 if (classof inputB) == array and (classof inputA) != array then return -1 if (classof inputB) == array and (classof inputA) == array then return (stricmp ((classof inputA[1]) as string) ((classof inputA[2]) as string)) return (stricmp ((classof inputA) as string) ((classof inputA) as string)) ); /*------------------------------------------------------------ # Name : rdt_sortHierarchyColor # Info : # Parms : inputA # inputB # Returns : --------------------------------------------------------------*/ function rdt_sortHierarchyColor inputA inputB = ( if (classof inputB) != array and (classof inputA) == array then return 1 if (classof inputB) == array and (classof inputA) != array then return -1 if (classof inputB) == array and (classof inputA) == array then return (rdt_sortColor inputA[1].wireColor inputB[1].wireColor) if (not (isProperty inputA #wireColor)) or (not (isProperty inputA #wireColor)) then return -1 if (not (isProperty inputB #wireColor)) or (not (isProperty inputB #wireColor)) then return 1 return (rdt_sortColor inputA.wireColor inputB.wireColor) ); /*------------------------------------------------------------ # Name : rdt_sortHierarchySize # Info : # Parms : inputA # inputB # Returns : --------------------------------------------------------------*/ function rdt_sortHierarchySize inputA inputB = ( if (classof inputB) != array and (classof inputA) == array then return 1 if (classof inputB) == array and (classof inputA) != array then return -1 if (classof inputB) == array and (classof inputA) == array then return (rdt_sortNumber (distance inputA[1].max inputA[1].min) (distance inputB[1].max inputB[1].min)) if (not (isProperty inputA #max)) or (not (isProperty inputA #min)) then return -1 if (not (isProperty inputB #max)) or (not (isProperty inputB #min)) then return 1 return (rdt_sortNumber (distance inputA.max inputA.min) (distance inputB.max inputB.min)); ); /*------------------------------------------------------------ # Name : rdt_matchNamesCase # Info : # Parms : inputArray # stringMatch # Returns : matchedObjs --------------------------------------------------------------*/ function rdt_matchNamesCase inputArray stringMatch = ( local matchedObjs = #() for eachObj in inputArray do ( if (matchPattern eachObj.name pattern:stringMatch ignoreCase:false) then append matchedObjs eachObj; ); return matchedObjs; ); /*------------------------------------------------------------ # Name : rdt_collectHierarchy # Info : # Parms : inputObj # sortMode # flatTree # Returns : objectHierarchy --------------------------------------------------------------*/ function rdt_collectHierarchy inputObj sortMode:#alph flatTree:false = ( local objectHierarchy = #() if flatTree then join objectHierarchy #(inputObj) else append objectHierarchy inputObj; if inputObj.children.count != 0 then ( for eachObj in inputObj.children do ( if flatTree then join objectHierarchy (rdt_collectHierarchy eachObj sortMode:sortMode flatTree:flatTree) else append objectHierarchy (rdt_collectHierarchy eachObj sortMode:sortMode) ); ); if sortMode == #alph then qsort objectHierarchy rdt_sortHierarchyAlph; if sortMode == #type then qsort objectHierarchy rdt_sortHierarchyType; if sortMode == #color then qsort objectHierarchy rdt_sortHierarchyColor; if sortMode == #size then qsort objectHierarchy rdt_sortHierarchySize; return objectHierarchy; ); /*------------------------------------------------------------ # Name : rdt_createTreeView # Info : # Parms : inputHierarchy # tabIndents # Returns : hieObjArray --------------------------------------------------------------*/ function rdt_createTreeView inputHierarchy tabIndents:-1 = ( local tabIndents; local hieObjArray = #(); if classof inputHierarchy == array then ( tabIndents += 1; for eachItem in inputHierarchy do ( join hieObjArray (rdt_createTreeView eachItem tabIndents:tabIndents); ); ) else ( if inputHierarchy != rootNode then ( join hieObjArray #(rdt_hieObj object:inputHierarchy name:inputHierarchy.name level:tabIndents isSelected:inputHierarchy.isSelected); ); ); return hieObjArray; ); /*------------------------------------------------------------ # Name : rdt_lower # Info : # Parms : inputString # # Returns : returnString --------------------------------------------------------------*/ function rdt_lower inputString = ( inputString = inputString as string local returnString = ""; local rdt_lowerCaseChrs = #("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); local upperCaseChrs = #("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"); for i = 1 to inputString.count do ( local letterPos = (findItem upperCaseChrs inputString[i]) if letterPos != 0 then returnString += rdt_lowerCaseChrs[letterPos] else returnString += inputString[i]; ); return returnString ); function rdt_refreshRollout = ( rlt_newSelectionTool.tmr_delayListUpdate.active = true; ); function rdt_rolloutAddcallbacks = ( callbacks.addScript #selectionSetChanged "rdt_refreshRollout();" id:#rlt_newSelectionTool; callbacks.addScript #nodeCreated "rdt_refreshRollout();" id:#rlt_newSelectionTool; callbacks.addScript #sceneNodeAdded "rdt_refreshRollout();" id:#rlt_newSelectionTool; callbacks.addScript #nodeFreeze "rdt_refreshRollout();" id:#rlt_newSelectionTool; callbacks.addScript #nodeUnFreeze "rdt_refreshRollout();" id:#rlt_newSelectionTool; callbacks.addScript #nodeHide "rdt_refreshRollout();" id:#rlt_newSelectionTool; callbacks.addScript #nodeUnHide "rdt_refreshRollout();" id:#rlt_newSelectionTool; callbacks.addScript #nodePostDelete "rdt_refreshRollout();" id:#rlt_newSelectionTool; callbacks.addScript #nodeRenamed "rdt_refreshRollout();" id:#rlt_newSelectionTool; ); /*------------------------------------------- Rollouts */ rollout rdt_updateRollout "Rodnet update check..." width:336 height:64 ( label lbl_question "Would you like to check for updates?" pos:[76,16] width:184 height:16 button btn_yes "Yes" pos:[8,40] width:80 height:16 button btn_no "No" pos:[168,40] width:80 height:16 button btn_never "Never" pos:[248,40] width:80 height:16 button btn_always "Always" pos:[88,40] width:80 height:16 on btn_yes pressed do ( destroyDialog rdt_updateRollout; rdt_updateScript = true; ); on btn_no pressed do ( destroyDialog rdt_updateRollout; rdt_updateScript = false; ); on btn_always pressed do ( destroyDialog rdt_updateRollout; setIniSetting "$max/ScriptFloaterSettings.ini" "rdt_updateRollout" "rdt_updateScript" "true"; rdt_updateScript = true; ); on btn_never pressed do ( destroyDialog rdt_updateRollout; setIniSetting "$max/ScriptFloaterSettings.ini" "rdt_updateRollout" "rdt_updateScript" "false"; rdt_updateScript = false; ); ); rollout rlt_newSelectionTool "Select By Name v3" width:400 height:409 ( /*------------------------------------------- Rollout Controls */ editText edt_stringFilter "" pos:[-3,2] width:259 height:16; activeXControl ax_objectList "{BDD1F04B-858B-11D1-B16A-00C0F0283628}" pos:[0,19] width:256 height:350 checkButton chkBtn_normal "normal" pos:[258,0] width:46 height:16 checked:true; checkButton chkBtn_hidden "hidden" pos:[304,0] width:46 height:16 checkButton chkBtn_frozen "frozen" pos:[350,0] width:46 height:16 groupBox grp_sort "Sort" pos:[258,16] width:140 height:78; radioButtons rdo_sort "" pos:[263,29] width:81 height:64 \ labels:#("Alphapetical", "By Type", "By Color", "By Size") \ default:1 columns:1; groupBox grp_listTypes "List Types" pos:[258,96] width:140 height:171; checkbox chk_listTypes_geo "Geometry" pos:[261,111] width:127 height:16 checked:true; checkbox chk_listTypes_shapes "Shapes" pos:[261,126] width:127 height:16 checked:true; checkbox chk_listTypes_lights "Lights" pos:[261,141] width:127 height:16 checked:true; checkbox chk_listTypes_cams "Cameras" pos:[261,156] width:127 height:16 checked:true; checkbox chk_listTypes_helpers "Helpers" pos:[261,171] width:127 height:16 checked:true; checkbox chk_listTypes_warps "Space Warps" pos:[261,186] width:127 height:16 checked:true; checkbox chk_listTypes_groups "Groups/Assemblies" pos:[261,201] width:127 height:16 checked:true; checkbox chk_listTypes_xrefs "XRefs" pos:[261,216] width:127 height:16 checked:true; checkbox chk_listTypes_bones "Bone Objects" pos:[261,231] width:127 height:16 checked:true; button btn_listTypes_all "All" pos:[261,248] width:45 height:16; button btn_listTypes_none "None" pos:[306,248] width:45 height:16; button btn_listTypes_invert "Invert" pos:[351,248] width:45 height:16; groupBox grp_selSets "Selection Sets" pos:[258,270] width:140 height:41; dropDownList ddl_selSet "" pos:[263,285] width:131 height:21; groupBox grp_opt "Options" pos:[259,312] width:140 height:77; checkbox chk1_opt_disST "Display Subtree" pos:[261,326] width:127 height:16; checkbox chk1_opt_selST "Select Subtree" pos:[261,341] width:127 height:16; checkbox chk1_opt_caseSen "Case Sensitive" pos:[261,356] width:127 height:16; checkbox chk1_opt_selDep "Select Dependents" pos:[261,371] width:127 height:16; button btn_all "All" pos:[1,376] width:85 height:16; button btn_none "None" pos:[86,376] width:85 height:16; button btn_invert "Invert" pos:[171,376] width:85 height:16; button btn_refresh "Refresh" pos:[260,392] width:69 height:16; button btn_close "Close" pos:[329,392] width:69 height:16; button btn_hide "Toggle Hide" pos:[1,392] width:85 height:16; button btn_freeze "Toggle Freeze" pos:[86,392] width:85 height:16; button btn_delete "Delete" pos:[171,392] width:85 height:16; timer tmr_delayUpdate "" interval:100 active:false; timer tmr_delayListUpdate "" interval:100 active:false; /*------------------------------------------- Rollout locals */ local classFilterChks = #( #(chk_listTypes_groups, #group), #(chk_listTypes_bones, #bone), #(chk_listTypes_xrefs, #xref), #(chk_listTypes_geo, #geometry), #(chk_listTypes_shapes, #shape), #(chk_listTypes_lights, #light), #(chk_listTypes_cams, #camera), #(chk_listTypes_helpers, #helper), #(chk_listTypes_warps, #spaceWarp)); local rlt_newSelectionToolBaseSize = [400, 409]; local trackYlist = #(btn_all, btn_none, btn_invert, btn_refresh, btn_close, btn_hide, btn_freeze, btn_delete); local trackXlist = #(grp_selSets, ddl_selSet, grp_opt, chk1_opt_disST, chk1_opt_selST, chk1_opt_caseSen, chk1_opt_selDep, grp_sort, rdo_sort, grp_listTypes, chk_listTypes_geo, chk_listTypes_shapes, chk_listTypes_lights, chk_listTypes_cams, chk_listTypes_helpers, chk_listTypes_warps, chk_listTypes_groups, chk_listTypes_xrefs, chk_listTypes_bones, btn_listTypes_all, btn_listTypes_none, btn_listTypes_invert, btn_refresh, btn_close, chkBtn_normal, chkBtn_hidden, chkBtn_frozen); /*------------------------------------------- Rollout Functions */ function getListSelected = ( local returnSelected = #(); for eachItem in rlt_newSelectionTool.ax_objectList.ListItems do ( if eachItem.selected then append returnSelected eachItem; ); return returnSelected; ); function setListSelected inputSelection = ( if rlt_newSelectionTool.ax_objectList.ListItems.count == 0 then return undefined; for eachItem in rlt_newSelectionTool.ax_objectList.ListItems do ( eachItem.selected = false; ); for eachItem in inputSelection do ( rlt_newSelectionTool.ax_objectList.ListItems[eachItem].selected = true; ); ); function invertListSelected = ( for eachItem in rlt_newSelectionTool.ax_objectList.ListItems do ( eachItem.selected = (not eachItem.selected); ); ); function updateObjectList inputObjs = ( rlt_newSelectionTool.ax_objectList.ListItems.Clear() lis = rlt_newSelectionTool.ax_objectList.listItems for eachItem in inputObjs do ( local li local detailTextColor = rdt_getColor #rdt_unknown reverse:true; local objVisState = true; local objFrozenState = false; if eachItem.object.isHidden then objVisState = false; if eachItem.object.isFrozen then objFrozenState = true; case (userClass eachItem.object) of ( #group:detailTextColor = rdt_getColor #rdt_group reverse:true; #bone:detailTextColor = rdt_getColor #rdt_bone reverse:true; #target:detailTextColor = rdt_getColor #rdt_target reverse:true; #geometry:detailTextColor = rdt_getColor #rdt_geometry reverse:true; #shape:detailTextColor = rdt_getColor #rdt_shape reverse:true; #light:detailTextColor = rdt_getColor #rdt_light reverse:true; #camera:detailTextColor = rdt_getColor #rdt_camera reverse:true; #helper:detailTextColor = rdt_getColor #rdt_helper reverse:true; #spaceWarp:detailTextColor = rdt_getColor #rdt_spaceWarp reverse:true; ); if (not objVisState) then detailTextColor += ((color 255 255 255) - detailTextColor) * (color 128 128 128); if (objFrozenState) then detailTextColor += ((color 255 255 255) - detailTextColor) * (color 128 128 128); li = lis.add(); li.text = ((rdt_createTabs eachItem.level) + eachItem.name) as string; li.ForeColor = detailTextColor; li.bold = true; li.ensureVisible(); sub_li_wireColor = li.ListSubItems.add(); sub_li_wireColor.text = (bit.intAsChar 143) + (bit.intAsChar 143); sub_li_wireColor.ForeColor = (color eachItem.object.wirecolor.b eachItem.object.wirecolor.g eachItem.object.wirecolor.r); sub_li_wireColor.bold = true; sub_li_class = li.ListSubItems.add(); sub_li_class.text = (userClass eachItem.object) as string; sub_li_class.ForeColor = rdt_getColor #rdt_text reverse:true; sub_li_state = li.ListSubItems.add(); sub_li_state.text = "n"; if eachItem.object.isHidden then sub_li_state.text = "h"; if eachItem.object.isFrozen then sub_li_state.text += "/f"; sub_li_state.ForeColor = rdt_getColor #rdt_text reverse:true; ); ); /*------------------------------------------------------------ # Name : .rolloutCallbacks # Info : # Parms : mode # # Returns : --------------------------------------------------------------*/ function rolloutCallbacks mode = ( if mode == #remove then callbacks.removeScripts id:#rlt_newSelectionTool; else if mode == #add then ( rdt_rolloutAddCallbacks(); ); ); /*------------------------------------------------------------ # Name : .updateClassFilter # Info : # Parms : # # Returns : --------------------------------------------------------------*/ function updateClassFilter = ( rdt_objectClassFilter = #() for eachFilterChk in classFilterChks do ( if eachFilterChk[1].checked then append rdt_objectClassFilter eachFilterChk[2]; ) ); /*------------------------------------------------------------ # Name : .refresh # Info : # Parms : renewObjs # # Returns : --------------------------------------------------------------*/ function refresh renewObjs:true = ( updateClassFilter(); local displayMode = #() local sortMode = case rdo_sort.state of ( 1:#alph 2:#type 3:#color 4:#size ); if chkBtn_normal.checked then append displayMode #normal; if chkBtn_hidden.checked then append displayMode #hidden; if chkBtn_frozen.checked then append displayMode #frozen; rdt_g_allObjects = (rdt_createTreeView (rdt_collectHierarchy rootnode sortMode:sortMode flatTree:(not chk1_opt_disST.checked))) rdt_g_allObjects = (rdt_filterObjClasses rdt_g_allObjects rdt_objectClassFilter displayMode:displayMode); local selectedObjs = #() for i = 1 to rdt_g_allObjects.count do ( if rdt_g_allObjects[i].isSelected then append selectedObjs i ); if renewObjs then ( updateObjectList (rdt_g_allObjects); ) setListSelected selectedObjs; try( ax_objectList.listItems[selectedObjs[selectedObjs.count]].EnsureVisible()) catch(); ); /*------------------------------------------------------------ # Name : .updateSelectionSets # Info : # Parms : # # Returns : --------------------------------------------------------------*/ function updateSelectionSets = ( local selectionSetNames = #(); for i = 1 to selectionSets.count do ( append selectionSetNames (getNamedSelSetName i); ); ddl_selSet.items = selectionSetNames; ); /*------------------------------------------------------------ # Name : .init # Info : # Parms : # # Returns : --------------------------------------------------------------*/ function init = ( if (colorman.getName #rdt_background) == undefined then rdt_setupDefaultColors(); updateClassFilter(); updateSelectionSets(); refresh(); rlt_newSelectionTool.ax_objectList.columnHeaders.clear(); rlt_newSelectionTool.ax_objectList.Appearance = #ccFlat rlt_newSelectionTool.ax_objectList.BorderStyle = #ccNone; rlt_newSelectionTool.ax_objectList.view = #lvwReport rlt_newSelectionTool.ax_objectList.FullRowSelect = true rlt_newSelectionTool.ax_objectList.multiSelect = true; rlt_newSelectionTool.ax_objectList.HideSelection = false; rlt_newSelectionTool.ax_objectList.LabelEdit = #lvwManual; rlt_newSelectionTool.ax_objectList.BackColor = rdt_getColor #rdt_background reverse:true; chs = rlt_newSelectionTool.ax_objectList.columnHeaders hNames = chs.Add(); hNames.text = "name"; hNames.Width = 3200; hWireColor = chs.Add(); hWireColor.text = "wireColor"; hWireColor.Width = 516; hClass = chs.Add(); hClass.text = "class"; hClass.Width = 1760; hState = chs.Add(); hState.text = "visibilityState"; hState.Width = 900; ); /*------------------------------------------------------------ # Name : .updateSelection # Info : # Parms : # # Returns : --------------------------------------------------------------*/ function updateSelection = ( rolloutCallbacks #remove; local newSelectionSet = #() local listSelection = getListSelected(); if listSelection.count == 0 then clearSelection(); for eachListSel in listSelection do ( if chk1_opt_selST.checked then join newSelectionSet (rdt_collectHierarchy rdt_g_allObjects[eachListSel.index].object flatTree:true) else append newSelectionSet rdt_g_allObjects[eachListSel.index].object; if chk1_opt_selDep.checked then for eachObj in (refs.dependents rdt_g_allObjects[eachListSel.index].object) do ( if (isProperty eachObj #isSelected) then append newSelectionSet eachObj; ); ); select newSelectionSet; if chk1_opt_selST.checked or chk1_opt_selDep.checked then refresh(); rolloutCallbacks #add; ); function saveRolloutSettings = ( for eachItem in rlt_newSelectionTool.controls do ( try ( setIniSetting "$max/ScriptFloaterSettings.ini" "rltFloater" (eachItem as string) (eachItem.state as string); ) catch ( ); ); ); function getRolloutSettings = ( for eachItem in rlt_newSelectionTool.controls do ( try ( currentStateClass = (classof eachItem.state); eachItem.state = (getIniSetting "$max/ScriptFloaterSettings.ini" "rltFloater" (eachItem as string)) as currentStateClass; ) catch ( ); ); ); /*------------------------------------------- Rollout Events */ on rlt_newSelectionTool open do ( getRolloutSettings(); rolloutCallbacks #remove; rolloutCallbacks #add; init(); ); on rlt_newSelectionTool close do ( callbacks.removeScripts id:#rlt_newSelectionTool; saveRolloutSettings(); ); --Contributed by Vsai (http://aeidigital.com) on rlt_newSelectionTool moved loc do ( vsaifloaterpos = [ loc.x , loc.y ]; setIniSetting "$max/ScriptFloaterPosition.ini" "rltFloater" "newSelectPosX" (vsaifloaterpos.x as string); setIniSetting "$max/ScriptFloaterPosition.ini" "rltFloater" "newSelectPosY" (vsaifloaterpos.y as string); ); on rlt_newSelectionTool resized value do ( if value.x < 400 then ( rlt_newSelectionTool.width = 400; value.x = 400; ); if value.y < 409 then ( rlt_newSelectionTool.height = 409; value.y = 409; ); differenceSize = (value - rlt_newSelectionToolBaseSize); for eachItem in trackYlist do ( eachItem.pos.y = eachItem.pos.y + differenceSize.y; ); for eachItem in trackXlist do ( eachItem.pos.x = eachItem.pos.x + differenceSize.x; ); try (edt_stringFilter.width = edt_stringFilter.width + differenceSize.x;) catch ( ); -- catch for max 6 users ax_objectList.ColumnHeaders[1].width = ax_objectList.ColumnHeaders[1].width + (differenceSize.x * 26.45); ax_objectList.size = ax_objectList.size + differenceSize; rlt_newSelectionToolBaseSize = [rlt_newSelectionTool.width, rlt_newSelectionTool.height]; setIniSetting "$max/ScriptFloaterSize.ini" "rltFloater" "newSelectWidth" (value.x as string); setIniSetting "$max/ScriptFloaterSize.ini" "rltFloater" "newSelectHeight" (value.y as string); ); /*------------------------------------------- Rollout Control Events */ on tmr_delayUpdate tick do ( updateSelection(); tmr_delayUpdate.active = false; ); on tmr_delayListUpdate tick do ( refresh(); tmr_delayListUpdate.active = false; ); on chkBtn_normal changed state do ( if keyboard.controlPressed then ( chkBtn_hidden.checked = false; chkBtn_frozen.checked = false; ); refresh(); ); on chkBtn_hidden changed state do ( if keyboard.controlPressed then ( chkBtn_normal.checked = false; chkBtn_frozen.checked = false; ); refresh(); ); on chkBtn_frozen changed state do ( if keyboard.controlPressed then ( chkBtn_hidden.checked = false; chkBtn_normal.checked = false; ); refresh(); ); on edt_stringFilter changed state do ( if edt_stringFilter.text != "" then ( local newSelection = (execute ("$'" + state + "*'")); if chk1_opt_caseSen.checked then newSelection = (rdt_matchNamesCase newSelection (state + "*")) if newSelection.count != 0 then select newSelection else clearSelection(); ); else clearSelection(); refresh(); ); on rdo_sort changed state do refresh(); on chk_listTypes_geo changed state do refresh(); on chk_listTypes_shapes changed state do refresh(); on chk_listTypes_lights changed state do refresh(); on chk_listTypes_cams changed state do refresh(); on chk_listTypes_helpers changed state do refresh(); on chk_listTypes_warps changed state do refresh(); on chk_listTypes_groups changed state do refresh(); on chk_listTypes_xrefs changed state do refresh(); on chk_listTypes_bones changed state do refresh(); on chk1_opt_disST changed state do refresh(); on ddl_selSet selected state do ( select selectionSets[state]; ); on btn_listTypes_all pressed do ( for eachFilterChk in classFilterChks do ( eachFilterChk[1].checked = true; ); refresh(); ); on btn_listTypes_none pressed do ( for eachFilterChk in classFilterChks do ( eachFilterChk[1].checked = false; ); refresh(); ); on btn_listTypes_invert pressed do ( for eachFilterChk in classFilterChks do ( eachFilterChk[1].checked = not eachFilterChk[1].checked; ); refresh(); ); on ax_objectList Click do ( updateSelection(); ); on ax_objectList MouseUp button shift x y do ( updateSelection(); ); on ax_objectList ItemClick item do ( tmr_delayUpdate.active = true; ); on btn_refresh pressed do ( refresh(); ); on btn_close pressed do ( destroyDialog rlt_newSelectionTool; ); on btn_all pressed do ( setListSelected #{1..ax_objectList.ListItems.count}; updateSelection(); ); on btn_none pressed do ( setListSelected #{}; updateSelection(); ); on btn_invert pressed do ( invertListSelected(); updateSelection(); ); on btn_hide pressed do ( undo label:(btn_hide.text + "...") on ( for eachItem in selection as array do ( eachItem.isHidden = (not eachItem.isHidden) ); ); updateSelection(); ); on btn_freeze pressed do ( undo label:(btn_freeze.text + "...") on ( for eachItem in selection as array do ( eachItem.isFrozen = (not eachItem.isFrozen) ); ); updateSelection(); ); on btn_delete pressed do ( undo label:(btn_delete.text + "...") on ( delete (selection as array); clearSelection(); ); ); ); /*------------------------------------------- Script init */ try (rdt_updateScript = (getinisetting "$max/ScriptFloaterSettings.ini" "rdt_updateRollout" "rdt_updateScript") as booleanClass) catch ( ); if rdt_updateScript == undefined then createDialog rdt_updateRollout modal:true; rdt_defineUpdateStruct(); local rolloutPosition = [ ((getinisetting "$max/ScriptFloaterPosition.ini" "rltFloater" "newSelectPosX") as integer), \ ((getinisetting "$max/ScriptFloaterPosition.ini" "rltFloater" "newSelectPosY") as integer)] local rolloutSize = [((getinisetting "$max/ScriptFloaterSize.ini" "rltFloater" "newSelectWidth") as integer), \ ((getinisetting "$max/ScriptFloaterSize.ini" "rltFloater" "newSelectHeight") as integer)]; if rolloutSize.x < 400 then rolloutSize.x = 400; if rolloutSize.y < 409 then rolloutSize.y = 409; createDialog rlt_newSelectionTool pos:rolloutPosition width:rolloutSize.x height:rolloutSize.y style:#(#style_resizing, #style_titlebar, #style_border, #style_sysmenu) setFocus rlt_newSelectionTool.btn_close; rlt_newSelectionTool.resized rolloutSize; );