Softimage SDK Programmer's Guide > Script Development > Working with Arrays (and Other Collections) in Softimage > Groups vs. Collections and Arrays >

# Using Native Softimage Commands To Access Groups

There are four basic actions when it comes to working with groups:

- Creating a group.

- Adding members to an existing group.

- Removing members from an existing group.

- Removing a group from the scene.

The next four sections provide demonstrations of how to do each of these actions, and all four code fragments may be run at once.

## To create a group with native Softimage commands

    ' Create a new model called "MyModel"
    Set oModel = GetPrim( "Null", "MyModel" )

    ' Create a new polymesh sphere called "MySphere"
    Set oSphere = CreatePrim( "Sphere", _
    	"MeshSurface", "MySphere" )

    ' Create a new group containing the model and sphere
    Set oGroup = CreateGroup( "MyGroup", oSphere & ", " _
    & oSphere & ".polymsh.cls.Point", oModel )

## To add items to a group with native Softimage commands

    ' Create a torus called "MyTorus"
    Set oTorus = CreatePrim( "Torus", _
       "MeshSurface", "MyTorus" )

    ' Add it to the group
    AddToGroup oGroup, oTorus

## To remove items from a group

    ' Remove "MySphere" from "MyGroup"
    RemoveFromGroup oGroup, oSphere

Note

If you added an object in branch mode to a group, to remove it you must select it properly, then use the RemoveFromGroup command without any parameters. For example:

    SelectObj "null", "BRANCH", True
    AddToGroup "Group"
    ' ...
    SelectObj "Group"
    AddToSelection "null", "BRANCH"
    RemoveFromGroup

## To remove a group from the scene

    RemoveGroup oGroup