---
name: "SoSwitch"
section: "3iv"
platform: "linux"
package: "inventor-doc"
version: "2.1.6+ds-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SoSwitch/3iv"
---

# SoSwitch(3iv)

group node that traverse one chosen child

## NAME

SoSwitch — group node that traverse one chosen child

## INHERITS FROM

SoBase \> SoFieldContainer \> SoNode \> SoGroup \> SoSwitch

## SYNOPSIS

**#include \<Inventor/nodes/SoSwitch.h\>**

Fields from class SoSwitch:

**SoSFInt32**	**whichChild**

Methods from class SoSwitch:

	**SoSwitch()**\
 	**SoSwitch(int nChildren)**\
 **static SoType**	**getClassTypeId()**

Methods from class SoGroup:

**void**	**addChild(SoNode \*child)**\
 **void**	**insertChild(SoNode \*child, int newChildIndex)**\
 **SoNode \***	**getChild(int index) const**\
 **int**	**findChild(const SoNode \*child) const**\
 **int**	**getNumChildren() const**\
 **void**	**removeChild(int index)**\
 **void**	**removeChild(SoNode \*child)**\
 **void**	**removeAllChildren()**\
 **void**	**replaceChild(int index, SoNode \*newChild)**\
 **void**	**replaceChild(SoNode \*oldChild, SoNode \*newChild)**

Methods from class SoNode:

**void**	**setOverride(SbBool state)**\
 **SbBool**	**isOverride() const**\
 **SoNode \***	**copy(SbBool copyConnections = FALSE) const**\
 **virtual SbBool**	**affectsState() const**\
 **static SoNode \***	**getByName(const SbName &name)**\
 **static int**	**getByName(const SbName &name, SoNodeList &list)**

Methods from class SoFieldContainer:

**void**	**setToDefaults()**\
 **SbBool**	**hasDefaultValues() const**\
 **SbBool**	**fieldsAreEqual(const SoFieldContainer \*fc) const**\
 **void**	**copyFieldValues(const SoFieldContainer \*fc, SbBool copyConnections = FALSE)**\
 **SbBool**	**set(const char \*fieldDataString)**\
 **void**	**get(SbString &fieldDataString)**\
 **virtual int**	**getFields(SoFieldList &resultList) const**\
 **virtual SoField \***	**getField(const SbName &fieldName) const**\
 **SbBool**	**getFieldName(const SoField \*field, SbName &fieldName) const**\
 **SbBool**	**isNotifyEnabled() const**\
 **SbBool**	**enableNotify(SbBool flag)**

Methods from class SoBase:

**void**	**ref()**\
 **void**	**unref() const**\
 **void**	**unrefNoDelete() const**\
 **void**	**touch()**\
 **virtual SoType**	**getTypeId() const**\
 **SbBool**	**isOfType(SoType type) const**\
 **virtual void**	**setName(const SbName &name)**\
 **virtual SbName**	**getName() const**

## DESCRIPTION

**This group node usually traverses only one or none of its children. It implements an operation similar to the switch** statement in C. One can use this node to switch on and off the effects of some properties or to switch between different properties.

The **whichChild** field specifies the index of the child to traverse, where the first child has index 0.

A value of **SO\_SWITCH\_NONE** (-1, the default) means do not traverse any children. A value of **SO\_SWITCH\_INHERIT** (-2) allows the index to be inherited from a previously-encountered **SoSwitch** node or from certain other nodes (such as **SoArray** or **SoMultipleCopy**) that set the switch value. A value of **SO\_SWITCH\_ALL** (-3) traverses all children, making the switch behave exactly like a regular **SoGroup**.

## FIELDS

**SoSFInt32**	**whichChild**\
 Index of the child to traverse, or one of **SO\_SWITCH\_NONE**, **SO\_SWITCH\_INHERIT**, or **SO\_SWITCH\_ALL**.

## METHODS

	**SoSwitch()**\
 Creates a switch node with default settings.

	**SoSwitch(int nChildren)**\
 Constructor that takes approximate number of children.

**static SoType**	**getClassTypeId()**\
 Returns type identifier for this class.

## ACTION BEHAVIOR

**SoGLRenderAction, SoCallbackAction, SoGetBoundingBoxAction, SoGetMatrixAction, SoHandleEventAction, SoRayPickAction**\
 Traverses the chosen child or children.

**SoSearchAction**\
 If the action's Searching-All flag is set, always traverses all children. Otherwise, traverses just the chosen child or children.

## FILE FORMAT/DEFAULTS

```
Switch {
whichChild	-1
}
```

## SEE ALSO

**SoArray, SoLevelOfDetail, SoMultipleCopy, SoPathSwitch**
