跳转到主要内容
套索元素之后才能调用这个接口,否则会调用失败。
static getLassoElements(): Promise<APIResponse<Element[]>>;
返回

示例

import { PluginCommAPI, ElementType, type Element } from 'sn-plugin-lib';

/**
 * 获取套索元素并按类型筛选的示例。
 */
export async function exampleGetLassoElements() {
  const res = await PluginCommAPI.getLassoElements();
  if (!res.success) {
    throw new Error(res.error?.message ?? 'getLassoElements 调用失败');
  }

  const elements = (res.result ?? []) as Element[];
  const strokes = elements.filter((e) => e.type === ElementType.TYPE_STROKE);
  return { elements, strokes };
}