Raise event every x seconds

Hello,

Any efficient way to call a function every x seconds? I won’t like to use delays as i think it will destroy the performance of my simulation.

I was thinking about using threading but I think is a lost cause in VC.

Regards!

Every X seconds of simulation time?
I think there shouldn’t really be performance issues with just a simple loop and delay in OnRun method of a Python script unless you have like hundreds of those per second or your expectations for simulation speed are very high.

You could also try making a Process Modeling process that just has a loop, delay, and e.g. a send signal statement.

PS: Don’t use Python print statement or other methods of output to test such things, because that is known to be relatively slow.

1 Like

Hi TSy,

You were right, I tried the delay () and it works fine at x100 speed. What was slowing down my simulation were some component parameters that were rebuilding continually the simulation.

PS: I recommend everyone to use the Optimize Rebuild addon, at least if you are as careless as I am when modeling.

1 Like