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

# SoCounter(3iv)

triggered integer counter

## NAME

SoCounter — triggered integer counter

## INHERITS FROM

SoBase \> SoFieldContainer \> SoEngine \> SoCounter

## SYNOPSIS

**#include \<Inventor/engines/SoCounter.h\>**

Inputs from class SoCounter:

**SoSFShort**	**min**\
 **SoSFShort**	**max**\
 **SoSFShort**	**step**\
 **SoSFTrigger**	**trigger**\
 **SoSFShort**	**reset**

Outputs from class SoCounter:

**(SoSFShort)**	**output**\
 **(SoSFTrigger)**	**syncOut**

Methods from class SoCounter:

	**SoCounter()**

Methods from class SoEngine:

**static SoType**	**getClassTypeId()**\
 **virtual int**	**getOutputs(SoEngineOutputList &list) const**\
 **SoEngineOutput \***	**getOutput(const SbName &outputName) const**\
 **SbBool**	**getOutputName(const SoEngineOutput \*output, SbName &outputName) const**\
 **SoEngine \***	**copy() const**\
 **static SoEngine \***	**getByName(const SbName &name)**\
 **static int**	**getByName(const SbName &name, SoEngineList &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 engine is a counter that outputs numbers, starting at a minimum value, increasing by a step value, and ending with a number that does not exceed the maximum value. It outputs the next number whenever** **the trigger** input is touched. When the maximum number is reached, it starts counting from the beginning again.

At any time the counter can be reset to a specific value by setting the **reset** input field to that value. The next time the counter is triggered it will start counting from there. Note that the counter will always output numbers based on the min, max and step values, and setting the reset value does not affect those input fields. If the reset value is not a legal counter value, the counter will still behave as though it is.

```
If reset is greater than max, the counter is set to max.
If reset is less than min, the counter is set to min.
If reset is between steps, the counter is set to the lower step value.
```

Each time a counting cycle is started, the **syncOut** output is triggered. This output can be used to synchronize some other event with the counting cycle.

## INPUTS

**SoSFShort**	**min**\
 Minimum value for the counter.

**SoSFShort**	**max**\
 Maximum value for the counter.

**SoSFShort**	**step**\
 Counter step value.

**SoSFTrigger**	**trigger**\
 Go to the next step.

**SoSFShort**	**reset**\
 At the next trigger, reset the counter to the specified value.

## OUTPUTS

**(SoSFShort)**	**output**\
 Counts min-to-max in step increments.

**(SoSFTrigger)**	**syncOut**\
 Triggers at cycle start.

## METHODS

	**SoCounter()**\
 Constructor

## FILE FORMAT/DEFAULTS

```
Counter {
min	0
max	1
step	1
trigger
reset	0
}
```

## SEE ALSO

**SoTimeCounter, SoEngineOutput**
