app.ActiveShape
当前选区里的第一个形状,等价 ActiveSelectionRange(1)。
签名
app.ActiveShape
说明
当前选区里的第一个形状,等价
ActiveSelectionRange(1)。Python 示例(可直接运行)
Python
shape = app.ActiveShape # 选区里的第一个形状
if shape is not None:
print("类型:", shape.Type) # 6=文字 7=群组 1=矩形 2=椭圆 3=曲线
else:
print("当前没有选中任何对象")
关于本类:Application 应用对象
整个 CDR 进程的入口,主要用来拿文档、拿当前选中、建颜色。
- 本类共 13 条,这是其中之一。
- 完整分类见:Application 应用对象
同类其他接口
- app.Documents所有已打开文档的集合。取第 i 个:app.Documents.Item(i),共 app.Documents.Count 个。
- app.ActiveDocument当前激活文档。一个都没开时返回 None,所以要写 try/except 兜底 CreateDocument。
- app.CreateDocument()新建空白文档,返回 Document。
- app.OpenDocument(path)打开磁盘上的 cdr / 模板文件,返回 Document。
- app.ActiveSelectionRange(n)当前选中的第 n 个形状,返回单个 Shape。刚 Import 完图片立刻用它抓图(n 从 1 开始)。
- app.ActiveSelectionRange不带参数返回整个选区(ShapeRange),可 for s in rng 遍历。
- app.ActivePage当前页。等价 ActiveDocument.ActivePage。
- app.ActiveLayer当前图层。等价 ActiveDocument.ActivePage.ActiveLayer。