
# IPCB_Model interface

The 3D model of a component body ([`IPCB_ComponentBody`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md)), one of an extruded shape, a cylinder, a sphere or a generic model.

```csharp
public interface IPCB_Model : IPCB_ModelProperties_Base
```

**Namespace:** PCB · **Assembly:** Altium.SDK.Interfaces

**Inherits:** [IPCB_ModelProperties_Base](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ModelProperties_Base.md)

## Remarks

A model is created by one of the component body's model factory methods, such as [`IPCB_ComponentBody.ModelFactory_FromFilename`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_fromfilename) or [`IPCB_ComponentBody.ModelFactory_CreateExtruded`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_createextruded), and assigned to the body with [`IPCB_ComponentBody.Model`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#model).

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [Embed](#embed) | `bool` | get; set | Whether the model data is embedded in the document. |
| [ItemGUID](#itemguid) | `string` | get; set | The GUID of the server item that the model is linked to. |
| [ItemRevisionGUID](#itemrevisionguid) | `string` | get; set | The GUID of the server item revision that the model is linked to. |
| [ModelSource](#modelsource) | [TModelSource](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TModelSource.md) | get; set | Where the model comes from, a file (`TModelSource.eModelSource_File`) or a server (`TModelSource.eModelsource_Vault`). |
| [ModelType](#modeltype) | [T3DModelType](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/T3DModelType.md) | get; set | The kind of model, extruded, generic, cylinder or sphere. |
| [Origin](#origin) | [CoordPoint](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/CoordPoint.md) | get; set | The origin of the model, in internal units (10,000 per mil). |
| [Rotation](#rotation) | `double` | get; set | The rotation of the model, in degrees. |
| [VaultGUID](#vaultguid) | `string` | get; set | The GUID of the server (vault) that the model was taken from. |

### Embed

Whether the model data is embedded in the document.

```csharp
bool GetEmbed();
void SetEmbed(bool argValue);
```

**Type:** `bool` · **Access:** read/write

For cylinder and sphere models, assigning a value has no effect.

### ItemGUID

The GUID of the server item that the model is linked to.

```csharp
string GetItemGUID();
void SetItemGUID(string argValue);
```

**Type:** `string` · **Access:** read/write

### ItemRevisionGUID

The GUID of the server item revision that the model is linked to.

```csharp
string GetItemRevisionGUID();
void SetItemRevisionGUID(string argValue);
```

**Type:** `string` · **Access:** read/write

### ModelSource

Where the model comes from, a file (`TModelSource.eModelSource_File`) or a server (`TModelSource.eModelsource_Vault`).

```csharp
TModelSource GetModelSource();
void SetModelSource(TModelSource argValue);
```

**Type:** [TModelSource](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TModelSource.md) · **Access:** read/write

The accessors are extension methods of `IPCB_ModelHelper` (`using PCB;`).

### ModelType

The kind of model, extruded, generic, cylinder or sphere.

```csharp
T3DModelType GetState_ModelType();
void SetState_ModelType(T3DModelType argValue);
```

**Type:** [T3DModelType](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/T3DModelType.md) · **Access:** read/write

The accessors are extension methods of `IPCB_ModelHelper` (`using PCB;`).

**See also:** [T3DModelType](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/T3DModelType.md)

### Origin

The origin of the model, in internal units (10,000 per mil).

```csharp
CoordPoint GetOrigin();
void SetOrigin(CoordPoint argValue);
```

**Type:** [CoordPoint](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/CoordPoint.md) · **Access:** read/write

The accessors are extension methods of `IPCB_ModelHelper` (`using PCB;`).

### Rotation

The rotation of the model, in degrees.

```csharp
double GetRotation();
void SetRotation(double argNewValue);
```

**Type:** `double` · **Access:** read/write

Assigning `Rotation` changes only this angle; [`SetState`](#setstate) sets the rotations about the three axes and the offset along the Z axis.

### VaultGUID

The GUID of the server (vault) that the model was taken from.

```csharp
string GetVaultGUID();
void SetVaultGUID(string argValue);
```

**Type:** `string` · **Access:** read/write

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [AddTo](#addto) | `void` | Adds the model's geometry to the given 3D view, with the given transformation and name. |
| [AddToAssembly](#addtoassembly) | `void` | Adds the model's geometry to the given assembly of a 3D view, with the given transformation and name. |
| [AddToAssembly2](#addtoassembly2) | `void` | Adds the model's geometry to the given assembly of a 3D view, with the given transformation, name and colour. |
| [ExportToStep](#exporttostep) | `void` | Writes the model's 3D geometry to a STEP file. |
| [ForceCheck_IsStale](#forcecheck_isstale) | `bool` | Checks again whether the file the model data was loaded from has changed, and returns the result. |
| [GetChecksum](#getchecksum) | `uint` | Returns the checksum of the model data. |
| [GetDataHash](#getdatahash) | `string` | Returns the checksum of the model data as a decimal string. |
| [GetDataSize](#getdatasize) | `long` | Returns the size of the model data. |
| [GetFileName](#getfilename) | `string` | Returns the name of the file the model data was loaded from. |
| [GetState](#getstate) | `void` | Returns the model's rotation about the X, Y and Z axes and its offset along the Z axis. |
| [I_Replicate](#i_replicate) | [IPCB_Model](#) | Returns a copy of the model, of the same model type. |
| [I_ReplicateToGeneric](#i_replicatetogeneric) | [IPCB_Model](#) | Returns a copy of the model as a generic model (`T3DModelType.e3DModelType_Generic`). |
| [IsEmpty](#isempty) | `bool` | Returns whether the model has no model data. |
| [IsStale](#isstale) | `bool` | Returns whether the file the model data was loaded from is known to have changed. |
| [SetState](#setstate) | `void` | Sets the model's rotation about the X, Y and Z axes and its offset along the Z axis. |

### AddTo

Adds the model's geometry to the given 3D view, with the given transformation and name.

```csharp
void AddTo(IOccWrapper argViewWrapper, IPCB3D_Transformation argITransformation, string argName);
void AddTo(object argViewWrapper, object argITransformation, string argName);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argViewWrapper` | [IOccWrapper](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IOccWrapper.md) | value |
| `argITransformation` | [IPCB3D_Transformation](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB3D_Transformation.md) | value |
| `argName` | `string` | value |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ModelHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

### AddToAssembly

Adds the model's geometry to the given assembly of a 3D view, with the given transformation and name.

```csharp
void AddToAssembly(IOccWrapper argViewWrapper, int argssemblyIndex, IPCB3D_Transformation argITransformation, string argName);
void AddToAssembly(object argViewWrapper, int argssemblyIndex, object argITransformation, string argName);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argViewWrapper` | [IOccWrapper](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IOccWrapper.md) | value |
| `argssemblyIndex` | `int` | value |
| `argITransformation` | [IPCB3D_Transformation](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB3D_Transformation.md) | value |
| `argName` | `string` | value |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ModelHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

### AddToAssembly2

Adds the model's geometry to the given assembly of a 3D view, with the given transformation, name and colour.

```csharp
void AddToAssembly2(IOccWrapper argViewWrapper, int argssemblyIndex, IPCB3D_Transformation argITransformation, string argName, uint argColor);
void AddToAssembly2(object argViewWrapper, int argssemblyIndex, object argITransformation, string argName, uint argColor);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argViewWrapper` | [IOccWrapper](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IOccWrapper.md) | value |  |
| `argssemblyIndex` | `int` | value |  |
| `argITransformation` | [IPCB3D_Transformation](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB3D_Transformation.md) | value |  |
| `argName` | `string` | value |  |
| `argColor` | `uint` | value | The colour applied to the added geometry. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ModelHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

### ExportToStep

Writes the model's 3D geometry to a STEP file.

```csharp
void ExportToStep(string argFileName);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argFileName` | `string` | value | The path of the STEP file to write. When it is an empty string, nothing is written. |

**Returns:** nothing (`void`)

### ForceCheck_IsStale

Checks again whether the file the model data was loaded from has changed, and returns the result.

```csharp
bool ForceCheck_IsStale();
```

**Returns:** `bool`

The file named by [`GetFileName`](#getfilename) is read and its checksum is compared with that of the model data. A model found stale stays stale; otherwise the method returns false when the file cannot be opened or its path is relative. Returns true for a model without model data. [`IsStale`](#isstale) returns the stored result without reading the file.

### GetChecksum

Returns the checksum of the model data.

```csharp
uint GetChecksum();
```

**Returns:** `uint`

Returns 0 for a model without model data.

### GetDataHash

Returns the checksum of the model data as a decimal string.

```csharp
string GetDataHash(string argHashType);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argHashType` | `string` | value | Must be an empty string; any other value raises an error, because named hash algorithms are not supported. |

**Returns:** `string`

Returns an empty string for a model without model data.

### GetDataSize

Returns the size of the model data.

```csharp
long GetDataSize();
```

**Returns:** `long`

Returns 0 for a model without model data.

### GetFileName

Returns the name of the file the model data was loaded from.

```csharp
string GetFileName();
```

**Returns:** `string`

Returns an empty string for a model without model data.

### GetState

Returns the model's rotation about the X, Y and Z axes and its offset along the Z axis.

```csharp
void GetState(out double argRotX, out double argRotY, out double argRotZ, out int argDz);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argRotX` | `double` | out | Receives the rotation about the X axis, in degrees. |
| `argRotY` | `double` | out | Receives the rotation about the Y axis, in degrees. |
| `argRotZ` | `double` | out | Receives the rotation about the Z axis, in degrees. |
| `argDz` | `int` | out | Receives the offset along the Z axis, in internal units (10,000 per mil). |

**Returns:** nothing (`void`)

All four values are 0 for a model without model data.

### I_Replicate

Returns a copy of the model, of the same model type.

```csharp
IPCB_Model I_Replicate();
```

**Returns:** [IPCB_Model](#)

Extension method of `IPCB_ModelHelper` (`using PCB;`).

### I_ReplicateToGeneric

Returns a copy of the model as a generic model (`T3DModelType.e3DModelType_Generic`).

```csharp
IPCB_Model I_ReplicateToGeneric();
```

**Returns:** [IPCB_Model](#)

Extension method of `IPCB_ModelHelper` (`using PCB;`).

`Embed` of the copy is true. The SDK examples use it to replace a model that is not generic, such as an extruded one, by assigning the copy to the body's [`IPCB_ComponentBody.Model`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#model).

### IsEmpty

Returns whether the model has no model data.

```csharp
bool IsEmpty();
```

**Returns:** `bool`

### IsStale

Returns whether the file the model data was loaded from is known to have changed.

```csharp
bool IsStale();
```

**Returns:** `bool`

The method returns the stored result and does not read the file; [`ForceCheck_IsStale`](#forcecheck_isstale) checks the file again. Returns false for a model without model data.

### SetState

Sets the model's rotation about the X, Y and Z axes and its offset along the Z axis.

```csharp
void SetState(double argRotX, double argRotY, double argRotZ, int argDz);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argRotX` | `double` | value | The rotation about the X axis, in degrees. |
| `argRotY` | `double` | value | The rotation about the Y axis, in degrees. |
| `argRotZ` | `double` | value | The rotation about the Z axis, in degrees. |
| `argDz` | `int` | value | The offset along the Z axis, in internal units (10,000 per mil). |

**Returns:** nothing (`void`)

Does nothing for a model without model data. An angle outside the range 0 to 360 is brought into the range -180 to 180 by whole turns. The SDK examples call it on a new model before assigning the model to the body with [`IPCB_ComponentBody.Model`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#model).

**Examples:** [Extension_CreatePCBLib](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_CreatePCBLib/Source%20Code/Commands.cs#L96)

## Returned by

[IPCB_ComponentBody.Model](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#model), [IPCB_ComponentBody.ModelFactory_Create](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_create), [IPCB_ComponentBody.ModelFactory_CreateCylinder](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_createcylinder), [IPCB_ComponentBody.ModelFactory_CreateExtruded](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_createextruded), [IPCB_ComponentBody.ModelFactory_CreateSphere](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_createsphere), [IPCB_ComponentBody.ModelFactory_FromFilename](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_fromfilename), [IPCB_ComponentBody.ModelFactory_FromVault](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_fromvault)

## Accepted by

[IPCB_ComponentBody.ModelFactory_Destroy](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_destroy), [IPCB_ComponentBody.ModelFactory_Replace](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ComponentBody.md#modelfactory_replace)

## Examples

Used in the SDK examples: [Extension_CreatePCBLib](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_CreatePCBLib/Source%20Code/Commands.cs#L93).
