【发布时间】:2021-12-13 02:07:55
【问题描述】:
我正在使用 for 循环重复一项任务,该任务基本上删除了我的活动 Illustrator 文档中的特定对象。代码可以运行,但是当它结束时出现错误,我无法执行其余代码。
我的代码:
def top_file():
for y in range(1, pathCount + 1):
path_items = activeDoc.PathItems(y).Filled
if path_items is False:
path_items = activeDoc.PathItems(y)
path_items.Delete()
这是我得到的错误:
Traceback (most recent call last):
File "C:\Users\joelq\Desktop\Joy Automation\main.py", line 88, in <module>
top_file()
File "C:\Users\joelq\Desktop\Joy Automation\main.py", line 61, in top_file
path_items = activeDoc.PathItems(y).Filled
File "C:\Users\joelq\AppData\Local\Programs\Python\Python39\lib\site-packages\win32com\client\dynamic.py", line 226, in __call__
self._oleobj_.Invoke(*allArgs), self._olerepr_.defaultDispatchName, None
pywintypes.com_error: (-2147352567, 'Ocurrió una excepción.', (0, 'Adobe Illustrator', 'No such element', None, 0, -2147352565), None)
【问题讨论】: