# IRdAvatarEnum Interface Reference

Inherits IDispatch.

List of all members.

## Public Member Functions
HRESULT | SetActiveSpace ([in] BSTR szSpace)
HRESULT | GetAvatarsCount ([out, retval] RtUlong *pdwNumAvatars)
HRESULT | GetAvatarNode ([in] RtUlong dwIndex,[out, retval] BSTR *pszNode)
HRESULT | GetAvatarMatrix ([in] RtUlong dwIndex,[out, retval] VARIANT *pMatrix)
HRESULT | SetAvatarMatrix ([in] RtUlong dwIndex,[in] VARIANT matrix)

## Detailed Description

The IRdAvatarEnum interface provides methods for avatar enumeration in shared space.
Root-level name in the scripting engine's name space: Avatar

## Member Function Documentation

HRESULT IRdAvatarEnum::SetActiveSpace | ( | [in] BSTR | szSpace | ) |

Set scene root encapsulator and perform enumerator initialization.

Parameters:

  `[in]` | szSpace | Space node name.

Returns:
  standard HRESULT processing can be applied to returned value.

          //  AvatEnum is an attribute created on Script Editor's Attributes tab.
          //  AvatEnum is of type "Tools Package/Avatar enumerator DO".

          //  Used from a server-side script, where there may be
          //  a number of shared spaces running concurrently.
          //  Here we set the active space as desired.
          //  Space.CurrentScene() points to current shared space as seen from client.
          var owner = Space.CurrentScene();
          AvatEnum.SetActiveSpace(owner);

HRESULT IRdAvatarEnum::GetAvatarsCount | ( | [out, retval] RtUlong * | pdwNumAvatars | ) |

Get number of avatars.

Parameters:

  | [out,retval] | pdwNumAvatars value to be filled with avatars count.

Returns:
  standard HRESULT processing can be applied to returned value

          // get the shared space's avatar enumerator.
          AvatEnum = RsTool.GetAvatarsEnumerator(owner);
          // how many avatars in this space?
          var variableA = AvatEnum.GetAvatarsCount();
          // get avatar name. In this case last avatar's name in list.
          var variableB = AvatEnum.GetAvatarNode(variableA);

HRESULT IRdAvatarEnum::GetAvatarNode | ( | [in] RtUlong | dwIndex,
|  | [out, retval] BSTR * | pszNode |
| ) |  |  |

Get avatar node.

Parameters:

  `[in]` | dwIndex | Index of avatar node to retrieve
  | [out,retval] | pszNodeName Avatar node name

Returns:
  standard HRESULT processing can be applied to returned value.

          // get avatar node name. In this case last avatar's name in list.
          var variableB = AvatEnum.GetAvatarNode(variableA);

HRESULT IRdAvatarEnum::GetAvatarMatrix | ( | [in] RtUlong | dwIndex,
|  | [out, retval] VARIANT * | pMatrix |
| ) |  |  |

Get Avatar's matrix (position).

Parameters:

  `[in]` | dwIndex | Index of avatar the matrix is required
  | [out,retval] | pMatrix The Matrix data object (IRdMatrixfDisp - Math Package/Matrix Float Data)

Returns:
  standard HRESULT processing can be applied to returned value.

Remarks:
  This method only wrap reading the avatar's WldMatrix attribute, you can directly access it if you find it useful

          // get avatar's matrix.
          var Matrix = AvatEnum.GetAvatarMatrix(variableA);

HRESULT IRdAvatarEnum::SetAvatarMatrix | ( | [in] RtUlong | dwIndex,
|  | [in] VARIANT | matrix |
| ) |  |  |

Set Avatar's matrix (position).

Parameters:

  `[in]` | dwIndex | Index of avatar the matrix you want to change
  `[in]` | matrix | The new Matrix data object (IRdMatrixfDisp - Math Package/Matrix Float Data)

Returns:
  standard HRESULT processing can be applied to returned value.

Remarks:
  This method only wrap reading the avatar's OwnerMatrix attribute, you can directly access it if you find it useful