# llGetObjectPrimCount

*LSL function*

```lsl
integer integer llGetObjectPrimCount(key prim);
```

- `key prim`: UUID of the prim in the same region.

- Returns: `integer`
- Energy: 10

Avatars sitting on the object are not counted[^wiki-25bcb3]. Zero is returned if **prim**: (A) is not found, (B) is part of an attachment[^wiki-d1e48e], or (C) is not a prim.

[^wiki-25bcb3]: [llGetNumberOfPrims](/functions/llGetNumberOfPrims/) on the other hand does count avatars sitting on the object.
[^wiki-d1e48e]: Whether the attachment exception is a bug or a feature is unclear.

Returns an [integer](https://wiki.secondlife.com/wiki/integer) that is the total number of prims in the object that contains **prim**.

```lsl title="How to use" frame="terminal"
integer result = llGetObjectPrimCount(NULL_KEY);
```

## Caveats

- This cannot be used to detect if an avatar is seated (by checking for a non-zero return), use [llGetAgentInfo](/functions/llGetAgentInfo/) instead.
- The prim count for attachments are not returned. If possible use [llGetNumberOfPrims](/functions/llGetNumberOfPrims/) instead.

## Examples

<details open>
<summary>Example 1</summary>

```lsl collapse={11-18}
default
{
    touch_start(integer num)
    {
        integer prims = llGetObjectPrimCount(llGetKey());
        if (prims == 0)
        {
            // llGetObjectPrimCount returns zero for attachments.
            prims = llGetNumberOfPrims();
            // Avatars can't sit on attachments so this is ok.
        }
        llOwnerSay("This object has "
                    + (string)prims
                    + " prims and "
                    + (string)(llGetNumberOfPrims() - prims)
                    + " avatars.");
    }
}
```

</details>

## See also

### Functions

- [llGetNumberOfPrims](/functions/llGetNumberOfPrims/) — Returns the number of prims in the current object.
- [llGetObjectLinkKey](/functions/llGetObjectLinkKey/) — Returns the key of the link in the linkset an object.

---

*Source: [LlGetObjectPrimCount](https://wiki.secondlife.com/wiki/LlGetObjectPrimCount) on the Second Life Wiki. Content from the Second Life Wiki articles LlGetObjectPrimCount (revision 1217516, 2024-10-11) and Template:LSL Function/prim (revision 1168829, 2012-06-11), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llGetObjectPrimCount/
