Changing the SimSpeed leads to a time jump

Hi,

i would like to speed up the simulation at certain points during my simulation. I started the simulation with “real time” and used this code structure:

# Real Time Approach:
sim = getSimulation()

# do something

sim.SimSpeed = 2.0

# do something fast

sim.SimSpeed = 1.0

# do something

The problem is that when I set the SimSpeed to 1.0 again, a time jump happens and the simulation is stuck for a view seconds. When I do it by hand (setting it at the simulation panel) its no problem to switch to other SimSpeeds.

I found a workaround using “virtual time” and approximating the speeds to get a similar behaviour.

# Virtual Time Approach:
sim = getSimulation()

# do something

sim.SimSpeed = 0.036

# do something fast

sim.SimSpeed = 0.018 # approximately real time speed

# do something

This helped, not to get “time jumps”.

I was wondering if there is a way to prevent this “time jump” using real time.

Edit: Is there a way to “Fast Forward” during a recording? It looks like changing the simulation speed does not apply during the recording (manually, as well as programmatically).

Thanks in advance.

Solution: Add sim.continueRun() after setting the SimSpeed.

sim = getSimulation()

# do something

sim.SimSpeed = 2.0
sim.continueRun()

# do something fast

sim.SimSpeed = 1.0
sim.continueRun() 

# do something