# Group functions | OpenStaad Python

> Named collections of nodes, beams, plates, or solids for batch selection and assignment — an organizing tool, not a structural element.

Source: https://www.openstaad.com/docs/group

Every function is a method of the session `s = ops.connect()` (`from openstaad import ops`).

## Create

### CreateGroup

**Description**

Creates the group.

**Parameters**

- `group_type` (int): group type.
- `group_name` (str): group name.

**Returns**

None: This function does not return a value.

**Example**

```python
from openstaad import ops

s = ops.connect()
s.CreateGroup(1, "value")
```

### CreateGroupEx

**Description**

Creates the group ex.

**Parameters**

- `groupType` (int): group type.
- `groupName` (str): group name.
- `entityList` (list): entity list.

**Returns**

value: See the official OpenSTAAD API reference for this method's exact return semantics.

**Example**

```python
from openstaad import ops

s = ops.connect()
result = s.CreateGroupEx(1, "value", [1, 2])
print(result)
```

## Get

### GetGroupCount

**Description**
Get the count of groups for a specified group type.

**Parameters**
- grouptype index (int): The type of group.

| Index | Group Type                          |
|-------|--------------------------------------|
| 1     | Nodes                                |
| 2     | Members                              |
| 3     | Plates                               |
| 4     | Solids                               |
| 5     | Geometry (Members, Plates and Solids)|
| 6     | Floor (Floor beam)                   |

**Returns**
int: Number of groups of the given type.

**Example**
To use this function see the following example:
```python
from openstaad import ops

# Connect to the running STAAD.Pro session
s = ops.connect()
 
#Execute the function from geometry module
group_count = s.GetGroupCount(6)

print(group_count)
```

### GetGroupCountAll

**Description**

Returns the group count all.

**Parameters**

None.

**Returns**

raw: The raw return value from the underlying OpenSTAAD COM call. Refer to the official Bentley OpenSTAAD API reference for this method's exact return semantics.

**Example**

```python
from openstaad import ops

s = ops.connect()
result = s.GetGroupCountAll()
print(result)
```

### GetGroupEntities

**Description**
Retrieve a list of entities (typically beams) within a specified group.

**Parameters**
- group_name (str): The name of the group.

**Returns**
list: List of entity numbers belonging to the group.

**Example**
To use this function see the following example:
```python
from openstaad import ops

# Connect to the running STAAD.Pro session
s = ops.connect()
 
#Execute the function from geometry module
entities = s.GetGroupEntities("_DLOAD")

print(entities)
```

### GetGroupEntityCount

Returns the number of entities in a specified group in the current model.

This function retrieves the count of entities (such as members, nodes, etc.) that belong to a given group name in the current model.

##### Parameters

- **groupName**: Name of the group for which the entity count is required.

##### Return values

- **<Val>**: Number of entities in the specified group.
- **-1**: Unable to find the group or error occurred.

##### Example

```python
from openstaad import ops

# Instanciar el módulo Geometry
s = ops.connect()

# Obtener el número de entidades en el grupo "Group1"
entity_count = s.GetGroupEntityCount("Group1")
```

### GetGroupNames

**Description**
Retrieve the names of groups for a specified group type.

**Parameters**
- grouptype index (int): The type of group.

| Index | Group Type                          |
|-------|--------------------------------------|
| 1     | Nodes                                |
| 2     | Members                              |
| 3     | Plates                               |
| 4     | Solids                               |
| 5     | Geometry (Members, Plates and Solids)|
| 6     | Floor (Floor beam)                   |

**Returns**
list: List of group names.

**Example**
To use this function see the following example:
```python
from openstaad import ops

# Connect to the running STAAD.Pro session
s = ops.connect()
 
#Execute the function from geometry module
group_names = s.GetGroupNames(6)

print(group_names)
```

## Set/Assign

### UpdateGroup

**Description**

Updates the group.

**Parameters**

- `groupName` (str): group name.
- `update_option` (int): update option.
- `entityList` (list): entity list.

**Returns**

None: This function does not return a value.

**Example**

```python
from openstaad import ops

s = ops.connect()
s.UpdateGroup("value", 1, [1, 2])
```

## Delete

### DeleteGroup

**Description**

Deletes the group.

**Parameters**

- `groupName` (str): group name.

**Returns**

None: This function does not return a value.

**Example**

```python
from openstaad import ops

s = ops.connect()
s.DeleteGroup("value")
```

## Select

### SelectGroup

**Description**

Selects the group.

**Parameters**

- `bstrGroup` (str): bstr group.

**Returns**

raw: The raw return value from the underlying OpenSTAAD COM call. Refer to the official Bentley OpenSTAAD API reference for this method's exact return semantics.

**Example**

```python
from openstaad import ops

s = ops.connect()
result = s.SelectGroup("value")
print(result)
```
