macroScript PhotoshopSelectedMaterial category:"ColinScripts" tooltip:"Photoshop Selected Material" Icon:#("GameTools",2) ( local selectedObjs = getCurrentSelection() local photoshopPath = "" local iniFile=scriptsPath+"PSMaterial.ini" -- Holds the ini filename, saved in the max scripts directory local curSlot = 1 if not(doesFileExist iniFile) then ( if (local savePath = getOpenFileName caption:"Please locate \"Photoshop.exe\"" filename:"Photoshop.exe") != undefined then ( setINISetting iniFile "Photoshop" "Path" savePath photoshopPath = savePath ) ) else ( -- iniFile exists, get the photoshop path --if (hasINISetting iniFile "Photoshop" "Path") then ( try ( photoshopPath = getINISetting iniFile "Photoshop" "Path" ) catch ( if (local savePath = getOpenFileName caption:"Please locate \"Photoshop.exe\"" filename:"Photoshop.exe") != undefined then ( setINISetting iniFile "Photoshop" "Path" savePath photoshopPath = savePath ) ) ) /* Function taken from BlurScripts by Neil Blevins to avoid re-write, thanks Neil! ------------------------------------------------------------------------------- -- BSLib.ms -- By Neil Blevins (neil@soulburn3d.com) -- v 1.33 -- Created On: 09/18/00 -- Modified On: 06/28/02 -- tested using Max 4.2 */ fn get_maps_from_mat mat x = ( if mat.numsubs != 0 then ( for i = 1 to mat.numsubs do ( if mat[i] != undefined then ( if classof mat[i] == SubAnim then ( if superclassof mat[i].object == textureMap then ( if mat[i].object != undefined then append x mat[i].object ) ) get_maps_from_mat mat[i] x ) ) ) ) if (selectedObjs.count > 1) then messageBox "Please select only one object." beep:false else ( -- only 1 object is selected if (local mat = selectedObjs[1].material) == undefined then ( messageBox "No material applied to that object" beep:false ) else ( local mapsFromMat = #() local bitmapsToLoad = #() medit.PutMtlToMtlEditor mat activeMeditSlot if (classof mat) == MultiMaterial then ( messageBox "This object is a multimaterial...please help me figure out what to do with these." beep:false ) else ( -- Not a multisub material local pathsToExec = "" get_maps_from_mat mat mapsFromMat -- Separate out correctly linked bitmapTextures for i = 1 to mapsFromMat.count where (classof mapsFromMat[i]) == BitmapTexture and (doesFileExist mapsFromMat[i].filename) and (findItem bitmapsToLoad mapsFromMat[i].filename) == 0 do append bitmapsToLoad mapsFromMat[i].filename --bitmapsToLoad = makeUniqueArray bitmapsToLoad if (bitmapsToLoad.count != 0) then ( for b in bitmapsToLoad do ( pathsToExec += "\"" + b + "\" " ) --execMe = ("\"\"" + photoshopPath + "\" " + pathsToExec + "\"\"") --format "%\n" execMe --DOSCommand execMe shellLaunch photoshopPath ("\"" + pathsToExec + "\"") if not (MatEditor.isOpen()) then MatEditor.Open() ) ) ) ) )