vcSimulation.run() method

Hi,

I would like to create a button into a component that simply reset the
model and execute the simulation for a while in real time.

I to this:

def OnButton(arg):
sim = getSimulation()
app = getApplication()

sim.reset()
sim.SimSpeed = 1.0
sim.run(10)
app.render()

 

Tha problema is that VC 4.0.5 will crash when I call sim.run()

Where is my mistake?

Thanks

Luciano.

 

 

Hi,

I just tested your code, also with a button action but it works for me (VC 4.0.4 professional) .

Maybe change sim.run to sim.run(10.0) because it expects a float, but I don’t think that should be an issue.

My best guess is to contact the support.

Regards,

Hi. I am getting a similar result.

I am trying to run a simulation with

sim.run(200.0)

however, my visual components session crashes.

 

I’ve tested this in VC 4.1 and if I remebered correctly this was a known bug.

 

 

I have got it so it doesn’t crash but it just jumps to the end of the simulation and doesn’t play it.

If I remember correctly, there is a difference between run() and continueRun().

  • run(): runs the simulation for the specified time in background without visualization
  • continueRun(): runs the simulation for the specified time with visualization
Technically there are also be other ways to specify the simulation run time, but unfortunately there seem to be issues when trying to change the value of the property SimulationRunTime.

Like Job said, it is a known issue when trying to control the execution of simulation via Python script. Sorry, try using .NET API to create a simple .NET command that can start and stop the simulation based on a given time argument, and then call that command in your script using the netCommand([Float runtime]).