# Sandbox.ModelBuilder.AddMesh

## Overload 1

```csharp
ModelBuilder AddMesh(Mesh mesh)
```

Adds a mesh that is visible at every LOD level and in every body group.

### Parameters

- `mesh` (`Mesh`): The mesh to add. Null or invalid meshes are ignored.

### Returns

`ModelBuilder`

### Exceptions

- `System.ArgumentException`: The mesh has no vertex buffer.

## Overload 2

```csharp
ModelBuilder AddMesh(Mesh mesh, int lod)
```

Adds a mesh to an LOD level.

### Parameters

- `mesh` (`Mesh`): The mesh to add. Null or invalid meshes are ignored.
- `lod` (`int`): The LOD level, from 0 to 7. Negative values use level 0.

### Returns

`ModelBuilder`

### Exceptions

- `System.ArgumentException`: The mesh has no vertex buffer.

## Overload 3

```csharp
ModelBuilder AddMesh(Mesh mesh, string groupName, int choiceIndex)
```

Adds a mesh to a body group choice at LOD level 0.

### Parameters

- `mesh` (`Mesh`): The mesh to add. Null or invalid meshes are ignored.
- `groupName` (`string`): The body group name.
- `choiceIndex` (`int`): The choice index within the body group.

### Returns

`ModelBuilder`

### Exceptions

- `System.ArgumentException`: The group name is empty, or the mesh has no vertex buffer.
- `System.ArgumentOutOfRangeException`: The choice index is negative.
- `System.InvalidOperationException`: The model has more than 64 body group choices.

## Overload 4

```csharp
ModelBuilder AddMesh(Mesh mesh, int lod, string groupName, int choiceIndex)
```

Adds a mesh to an LOD level and body group choice.

### Parameters

- `mesh` (`Mesh`): The mesh to add. Null or invalid meshes are ignored.
- `lod` (`int`): The LOD level, from 0 to 7. Negative values use level 0.
- `groupName` (`string`): The body group name.
- `choiceIndex` (`int`): The choice index within the body group.

### Returns

`ModelBuilder`

### Exceptions

- `System.ArgumentException`: The group name is empty, or the mesh has no vertex buffer.
- `System.ArgumentOutOfRangeException`: The choice index is negative.
- `System.InvalidOperationException`: The model has more than 64 body group choices.

Declared in [Sandbox.ModelBuilder](/api/Sandbox.ModelBuilder).
Assembly: `Sandbox.Engine`.
