这是源代码
coding=utf-8
import win32com.client as COM
vissim_com=COM.Dispatch("Vissim.Vissim")
vissim_com.LoadNet('D:\vissim\test\21.inp')
vissim_com.LoadLayout('D:\vissim\test\vissim.ini')
vnet=http://vissim_com.Net
sim=vissim_com.Simulation
eval=vissim_com.Evaluation
datapoints=vnet.Datacollections
datapoint1=datapoints.GetDataCollectionByNumber(1)
ptime=7201
stime=5
sim.Period=ptime
sim.Resolution=stime
sim.Speed=0
a=[]
for i in range(3600):
sim.RunSingleStep
volume1=datapoint1.GetResult('NVEHICLES','SUM',0)
不知道为什么,出现错误:
File "D:/Control/testvissim.py", line 23, in
volume1=datapoint1.GetResult('NVEHICLES','SUM',0)
File "", line 3, in GetResult
File "D:\anaconda\lib\site-packages\win32com\client\dynamic.py", line 287, in ApplyTypes
result = self.oleobj.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
pywintypes.com_error: (-2147352567, '发生意外。', (0, None, 'Method call only possible during a simulation run.', 'VISSIMCOM.HLP', 131200, -2147467259), None)