Skip to main content

Home > blockly > Workspace > getBlocksByType

Workspace.getBlocksByType() method

Finds the blocks with the associated type and returns them. Blocks are optionally sorted by position; top to bottom (with slight LTR or RTL bias).

Signature:

getBlocksByType(type: string, ordered?: boolean): Block[];

Parameters

ParameterTypeDescription
typestringThe type of block to search for.
orderedboolean(Optional) Sort the list if true.

Returns:

Block[]

The blocks of the given type.