我在一个模板幻灯片中有一个自由形式的对象,我想要复制和制作多个对象。
我在文档中找不到一种方法来从预先存在的形状创建形状。我是不是找错地方了,还是那个功能不存在?
发布于 2018-10-10 02:24:50
python-pptx API不支持此操作,但您可能可以使用一些内部工具来实现此结果。
from copy import deepcopy
# ---get the existing freeform shape however you do---
freeform = slide.shapes[n]
# ---get the underlying XML element for that shape---
sp = freeform._sp
for idx in range(3):
# ---duplicate original freeform---
new_sp = deepcopy(sp)
# ---create a unique id for it---
new_sp.nvSpPr.cNvPr.id = 1000 + idx
# ---insert it after original---
sp.addnext(new_sp)这些都将直接堆叠在原来的,所以你可能想要添加一些,以移动他们到一个新的位置。此外,如果现有的freeform参与了一个超链接,或者它本身就是一个链接,或者包含有一个超链接的文本,那么您可能会遇到麻烦。
https://stackoverflow.com/questions/52728142
复制相似问题