跳转到内容

Selection

读取和设置当前 Figma 选区。

Type reference
// Selection is the set of nodes currently highlighted in the Figma canvas.
// get returns the current selection. Without depth, returns stubs ({id, name, type}). With depth=0, returns full properties.
// _truncated: true when the response was cut short due to node budget limits. Use depth=0 or specific fields to reduce payload.
// set replaces the entire selection AND scrolls the viewport to show the selected nodes.

2 methods available.

Get the current selection

ParameterTypeRequiredDescription
depthnumberChild recursion depth. Omit for stubs only, 0=selected nodes' properties, -1=unlimited.
verbosebooleanInclude all properties (bounding box, constraints, text style details). Default false — returns slim, actionable output.

Response

FieldTypeDescription
resultsobject[]
idstring
namestring
typestring
_truncatedboolean
_noticestring
Example response
{
"results": [
{
"id": "1:2",
"name": "Button",
"type": "COMPONENT"
}
]
}

Set selection to nodes and scroll viewport to show them

ParameterTypeRequiredDescription
nodeIdsstring[]Array of node IDs to select. Example: ["1:2","1:3"]

Response

FieldTypeDescription
countnumberNumber of nodes selected
selectedNodesobject[]
namestring
idstring
notFoundIdsstring[]IDs that could not be found
Example response
{
"count": 2,
"selectedNodes": [
{
"name": "Button",
"id": "1:2"
},
{
"name": "Card",
"id": "3:4"
}
]
}