使用 Python COM 编写 Photoshop 脚本。复制和扁平化问题
Photoshop scripting with Python COM. Duplicate and flatten problems
我正在尝试合并一些 PS 文件,主要使用两种方法:
1) 拼合、全选、复制、更改 ActiveDocument 和粘贴。这个 return 第一步中的 TypeError。
Traceback (most recent call last):
File "C:\..\Merge.py", line 5, in <module>
doc.flatten()
TypeError: 'NoneType' object is not callable
[Finished in 0.7s]
在 Photoshop 中我可以观察到文件被压平了,但是 return 这个。停止脚本。
2) 指向目标文档的重复 LayerSet。
Traceback (most recent call last):
File "C:\..\Merge.py", line 27, in <module>
appRef.activeDocument.LayerSets[0].duplicate(appRef.documents[0]);
File "C:\python27-64\lib\site-packages\win32com\client\dynamic.py", line 197, in __call__
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
[Finished in 4.7s]
同样如此! LayerSet 重复
- Photoshop CC 2014 64 位
- Python 2.7 64 位
- 用于 python 2.7 64 位的 Win32com
显然,win32com 有问题。
comtypes 效果很好! re-installing python 2.7 64 位。检查 "Install for me only" 而不是 "Install for all users" 然后安装 comtypes。
我正在尝试合并一些 PS 文件,主要使用两种方法:
1) 拼合、全选、复制、更改 ActiveDocument 和粘贴。这个 return 第一步中的 TypeError。
Traceback (most recent call last):
File "C:\..\Merge.py", line 5, in <module>
doc.flatten()
TypeError: 'NoneType' object is not callable
[Finished in 0.7s]
在 Photoshop 中我可以观察到文件被压平了,但是 return 这个。停止脚本。
2) 指向目标文档的重复 LayerSet。
Traceback (most recent call last):
File "C:\..\Merge.py", line 27, in <module>
appRef.activeDocument.LayerSets[0].duplicate(appRef.documents[0]);
File "C:\python27-64\lib\site-packages\win32com\client\dynamic.py", line 197, in __call__
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
[Finished in 4.7s]
同样如此! LayerSet 重复
- Photoshop CC 2014 64 位
- Python 2.7 64 位
- 用于 python 2.7 64 位的 Win32com
显然,win32com 有问题。
comtypes 效果很好! re-installing python 2.7 64 位。检查 "Install for me only" 而不是 "Install for all users" 然后安装 comtypes。