Momentum Scripting v1
Deprecated API version. Use Momentum.v2 for new scripts.
Loading...
Searching...
No Matches
Migrating from the deprecated v1 API

Use Momentum.v2 for new scripts. Momentum.v1 is deprecated but remains available: existing scripts and imported dependencies can keep using their original names and units.

Browse the Momentum.v2 namespace for the updated classes, utility functions, and constants.

API names in v2

The table compares v1 and v2 getter names. Apply the same rename to the corresponding setter.

Parameter Previous getter New getter
Translational stiffness getTranslationalElasticity() getTranslationalStiffness()
Rotational stiffness getRotationalElasticity() getRotationalStiffness()
Secondary spring stiffness getElasticity() getStiffness()
Distance spring stiffness getSpringElasticity() getSpringStiffness()
Motor position-holding damping getDamping() getHoldPositionDamping()
Material-pair stabilization getDamping() getAttenuation()

Physical spring damping stays physical. Its getter/setter names and viscous damping coefficients remain available. Motor position-holding damping applies when spring-at-zero-speed mode is enabled and the target speed is zero.

Convert material-pair damping values

Material-pair damping in v1 is a time in seconds. Attenuation in v2 is a number of integration steps, with no physical unit. Renaming the methods alone would change the meaning of the value.

Use these conversions, where tau is damping time and h is the active simulation timestep, both in seconds:

  • Damping time to attenuation: n = tau / h.
  • Attenuation to damping time: tau = n * h.

Set a damping time through v2

Replace a v1 pair.setDamping(dampingTime) call with:

from Momentum import v2
pair.setAttenuation(v2.convertDampingTimeToAttenuation(dampingTime))

Read attenuation through v2

Note
A material-pair getter in v2 returns attenuation n (dimensionless integration steps), whereas the v1 getter returns damping time tau in seconds. The conversion is n = tau / h, or tau = n * h, where h is the active simulation timestep in seconds. Review calculations that use the returned value.

Replace a v1 pair.getDamping() call with:

attenuation = pair.getAttenuation() # dimensionless integration steps

Obtain pair through the v2 API. The setter conversion utility converts material-pair damping time; it does not convert viscous spring damping coefficients.

Changing the timestep

The utilities use the active simulation timestep. If the timestep changes, reapply the setter conversion to preserve a damping time in seconds. A stored attenuation value alone does not retain a timestep-independent damping time.