# Retrieve an Attribute from an EPointCloud

The code shows how to retrieve an attribute from a cloud.

## C++

```cpp
#include <eVision/Easy3D/EPointCloud.h>
```

```cpp
using namespace eVision;
using namespace eVision::Easy3D;
EPointCloud cloud;
const EC24A* data;

// case 1: data is Color, Normal, Intensity, Texture, Index, Confidence or Distance
data = static_cast<const EC24A*>(cloud.GetAttributeBuffer(E3DAttribute_Color));

// case 2: data is something else
int attributeOffset = 17;  // value retrieved when we initialized the attribute
data = static_cast<const EC24A*>(cloud.GetAttributeBuffer(attributeOffset));
```

## C#

```cs
using System;
using System.Runtime.InteropServices;

using eVision.Easy3D;
```

```cs
EPointCloud cloud = new EPointCloud();
int ItemsizeInBytes = 4;  // an EC24A is 4 bytes
Byte[] data = new Byte[cloud.NumPoints * ItemsizeInBytes];

// case 1: data is Color, Normal, Intensity, Texture, Index, Confidence or Distance
Marshal.Copy(cloud.GetAttributeBuffer((int)E3DAttribute.Color), data, 0, cloud.NumPoints * ItemsizeInBytes);

// case 2: data is something else
int attributeOffset = 17;  // value retrieved when we initialized the attribute
Marshal.Copy(cloud.GetAttributeBuffer(attributeOffset), data, 0, cloud.NumPoints * ItemsizeInBytes);
```

## Python

```py
from eVision import Easy3D
import numpy as np
import ctypes as ct
cloud = Easy3D.EPointCloud()

# case 1: data is Color, Normal, Intensity, Texture, Index, Confidence or Distance
ptr_raw = cloud.GetAttributeBuffer(Easy3D.E3DAttribute.Color)
ptr = ct.cast(ptr_raw, ct.POINTER(ct.c_ubyte))  # cast to ct.c_ubyte because EC24A is treated as 4 bytes
color = np.ctypeslib.as_array(ptr, shape=(cloud.NumPoints, 4))
# color's EC24A components are in BGRA order (color[:, 0] is blue pixel)
# numpy doesn't own memory, do not use once cloud gets out of scope

# case 2: data is something else
ptr_raw = cloud.GetAttributeBuffer(7)  # value retrieved when we initialized the attribute
ptr = ct.cast(ptr_raw, ct.POINTER(ct.c_float))  # cast to ct.c_float because attribute is a float
attribute = np.ctypeslib.as_array(ptr, shape=(cloud.NumPoints,))
```
