# CreateBlockNode

> Creates and inserts a new BlockNode into this context node.

## Definition

* **Type:** Method
* **Namespace:** [Unity.GraphToolkit.Editor](/engine/6000.6/script-reference/unity/graphtoolkit/editor.md)
* **Assembly:** UnityEditor

## CreateBlockNode\<T>(int)

Creates and inserts a new [BlockNode](/engine/6000.6/script-reference/unity/graphtoolkit/editor/blocknode.md) into this context node.

```csharp
public void CreateBlockNode<TBlockNode>(int index = -1) where TBlockNode : BlockNode, new()
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Optional. The zero-based index where to insert the block node. Defaults to -1, which appends the block at the bottom of the context node.

### Remarks

Use this method when you want to create and add a new block node of a specific type to the context. Consider using [ContextNode.AddBlockNode](/engine/6000.6/script-reference/unity/graphtoolkit/editor/contextnode/addblocknode.md) or [ContextNode.InsertBlockNode](/engine/6000.6/script-reference/unity/graphtoolkit/editor/contextnode/insertblocknode.md) when you already have an existing block node instance, Blocks are ordered vertically: index 0 is the topmost block, and higher indices go toward the bottom. When `index` is less than 0 or equal to the current block count, the block is added at the bottom. Throws ArgumentException if `index` is greater than the current block count.

## CreateBlockNode(Type, int)

Creates and inserts a new [BlockNode](/engine/6000.6/script-reference/unity/graphtoolkit/editor/blocknode.md) into this context node.

```csharp
public void CreateBlockNode(Type blockNodeType, int index = -1)
```

### Parameters

**** (\[Type]\(https\://learn.microsoft.com/dotnet/api/system.type)): The type of the block node to create and insert. Must inherit from [BlockNode](/engine/6000.6/script-reference/unity/graphtoolkit/editor/blocknode.md)..**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Optional. The zero-based index where to insert the block node. Defaults to -1, which appends the block at the bottom of the context node.

### Remarks

Use this method when you want to create and add a new block node of a specific type to the context. Consider using [ContextNode.AddBlockNode](/engine/6000.6/script-reference/unity/graphtoolkit/editor/contextnode/addblocknode.md) or [ContextNode.InsertBlockNode](/engine/6000.6/script-reference/unity/graphtoolkit/editor/contextnode/insertblocknode.md) when you already have an existing block node instance, Blocks are ordered vertically: index 0 is the topmost block, and higher indices go toward the bottom. When `index` is less than 0 or equal to the current block count, the block is added at the bottom. Throws ArgumentException if `index` is greater than the current block count.
