By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,737 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,737 IT Pros & Developers. It's quick & easy.

Python / Visum Error Message

P: 1
Hi, if anyone can help me unscramble this exception report from Python I'd be hugely grateful. All I'm trying to do is carry out is call VISUM and carry a flow bundle. I think the problem may be with the Python installation rather than the script.

Many thanks,

Stephen

I've got the following code:
Expand|Select|Wrap|Line Numbers
  1. import VisumPy.helpers
  2. #from VisumPy.helpers import CreateVisum
  3.  
  4. Visum = VisumPy.helpers.CreateVisum(115)
  5. fileNames = ["Base06_AM_DS"]
  6.  
  7. for fileName in fileNames: 
  8.     Visum.LoadVersion(r"Y:/07 Forecasting/10 Review of Highway Model/Test/" + fileName)
  9.  
  10. #flow bundle execute and save matrix
  11.  
  12. fn = 119545498
  13. tn = 119545499
  14.  
  15. # UC1
  16. dseg = "UC1"
  17. filename = "Y:/07 Forecasting/10 Review of Highway Model/Test/AA16DS_AM_SLA1_NB_UC1_F.mtx"
  18. netElem = Visum.CreateNetElements()
  19. link = Visum.Net.Links.ItemByKey(fn, tn)
  20. netElem.add(link)
  21. fb = Visum.Net.DemandSegments.ItemByKey(dseg).FlowBundle
  22. fb.Execute(netElem)
  23. fb.Save(filename,"O") 
  24.  
  25. #   Visum.Procedures.Execute()
  26. Visum.SaveVersion(r"Y:/07 Forecasting/10 Review of Highway Model/Test/" + fileName) 
------------------------------------------

And then this is the error message I get:

File "C:\Python25\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py" , line 309, in RunScript
debugger.run(codeObject, __main__.__dict__, start_stepping=0)
File "C:\Python25\Lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run
_GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
File "C:\Python25\Lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 624, in run
exec cmd in globals, locals
File "Y:\07 Forecasting\10 Review of Highway Model\Test\Oa_Original_SLA.py", line 21, in <module>
netElem.add(link)
File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__
raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr)
AttributeError: '<win32com.gen_py.Visum Object Library 11.5.INetElements instance at 0x22624096>' object has no attribute 'add'
>>>
Jan 30 '12 #1
Share this Question
Share on Google+
1 Reply

Smygis
100+
P: 126
I can't find documentation on this module so im not sure whats going on. (PTV.de? my german is not good enough to figure out if the site is relevant)

What you could do is open up a python window and run the program line by line until you get to
Expand|Select|Wrap|Line Numbers
  1. netElem = Visum.CreateNetElements()
And then run:
Expand|Select|Wrap|Line Numbers
  1. dir(netElem)
And see what happens. The error seems to be about it not having a .add(), and i suppose if it looks strange that module might be corrupt or something.
Feb 1 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.