跳到主要内容

GetDrawingsByPlaceholderType

按指定的占位符类型返回绘图数组。

语法

expression.GetDrawingsByPlaceholderType(sType);

expression - 表示 ApiSlide 类的变量。

参数

名称必需/可选数据类型默认值描述
sType必需PlaceholderType占位符类型。

返回值

Drawing[]

示例

此示例按占位符类型获取绘图并将其从幻灯片中移除。

// How to get all drawings knowing its placeholder as an array.

// Retrieve drawings with the specified placeholder and delete them.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);
shape.SetSize(300 * 36000, 130 * 36000);

const placeholder = Api.CreatePlaceholder("chart");
shape.SetPlaceholder(placeholder);
slide.AddObject(shape);
const drawingsWithPh = slide.GetDrawingsByPlaceholderType("chart");
for (let i = 0; i < drawingsWithPh.length; i++) {
drawingsWithPh[i].Delete();
}