MaxScript通过Ole操作Phtoshop的范例,将几张图按图层合并为psd
也是在qq群遇到的网友的问题,,实际上如果只是合并成psd也可以找.net的库来做,不过大部分库都是只能读不能写,是因为psd的授权问题。此外也为了普及一下ole这个老古董。不过这段代码只操作cs6通过,其他photoshop的版本可能有改动。
Fn CombineTextureToPSD inputSourceArray inputSavePsdFile photoshopExit:true = ( if inputSourceArray.Count > 1 do ( Global PhotoshopApplication PhotoshopApplication = createOLEObject "Photoshop.Application" for tempFileName in inputSourceArray do ( PhotoshopApplication.Load tempFileName ) for i =2 to inputSourceArray.Count do ( PhotoshopApplication.ActiveDocument = PhotoshopApplication.Documents i PhotoshopApplication.ActiveDocument.Selection.SelectAll() PhotoshopApplication.ActiveDocument.Selection.Copy() PhotoshopApplication.ActiveDocument = PhotoshopApplication.Documents 1 PhotoshopApplication.ActiveDocument.Paste() ) PhotoshopApplication.ActiveDocument.SaveAs inputSavePsdFile /* 早期版本可能是 PhotoshopApplication.Documents.Length */ while PhotoshopApplication.Documents.Count > 0 do PhotoshopApplication.ActiveDocument.Close 2 if photoshopExit == True do ( PhotoshopApplication.Quit() ReleaseOLEObject PhotoshopApplication PhotoshopApplication = undefined GC() ) ) ) CombineTextureToPSD #("d:\\test\\test1.png","d:\\test\\test2.png") "d:\\test\\test.psd"