跳到主要内容

GetLayout

按位置返回指定幻灯片母版的版式。

语法

expression.GetLayout(nPos);

expression - 表示 ApiMaster 类的变量。

参数

名称必需/可选数据类型默认值描述
nPos必需number版式位置。

返回值

ApiLayout | null

示例

按索引位置从幻灯片母版检索布局。

// Access the master and create a layout object to apply to a slide.

// Add the layout to the master and apply it to the current slide.

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

const layout = Api.CreateLayout();
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);

layout.AddObject(shape);
master.AddLayout(0, layout);
slide.ApplyLayout(master.GetLayout(0));