Python / Visum Error Message

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stephen flacke
    New Member
    • Jan 2012
    • 1

    Python / Visum Error Message

    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:
    Code:
    import VisumPy.helpers
    #from VisumPy.helpers import CreateVisum
    
    Visum = VisumPy.helpers.CreateVisum(115)
    fileNames = ["Base06_AM_DS"]
    
    for fileName in fileNames: 
        Visum.LoadVersion(r"Y:/07 Forecasting/10 Review of Highway Model/Test/" + fileName)
    
    #flow bundle execute and save matrix
    
    fn = 119545498
    tn = 119545499
    
    # UC1
    dseg = "UC1"
    filename = "Y:/07 Forecasting/10 Review of Highway Model/Test/AA16DS_AM_SLA1_NB_UC1_F.mtx"
    netElem = Visum.CreateNetElements()
    link = Visum.Net.Links.ItemByKey(fn, tn)
    netElem.add(link)
    fb = Visum.Net.DemandSegments.ItemByKey(dseg).FlowBundle
    fb.Execute(netElem)
    fb.Save(filename,"O") 
    
    #   Visum.Procedures.Execute()
    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\Li b\site-packages\Python win\pywin\frame work\scriptutil s.py", line 309, in RunScript
    debugger.run(co deObject, __main__.__dict __, start_stepping= 0)
    File "C:\Python25\Li b\site-packages\Python win\pywin\debug ger\__init__.py ", line 60, in run
    _GetCurrentDebu gger().run(cmd, globals,locals, start_stepping)
    File "C:\Python25\Li b\site-packages\Python win\pywin\debug ger\debugger.py ", line 624, in run
    exec cmd in globals, locals
    File "Y:\07 Forecasting\10 Review of Highway Model\Test\Oa_O riginal_SLA.py" , line 21, in <module>
    netElem.add(lin k)
    File "C:\Python25\li b\site-packages\win32c om\client\__ini t__.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.INetElemen ts instance at 0x22624096>' object has no attribute 'add'
    >>>
    Last edited by bvdet; Jan 30 '12, 05:35 PM. Reason: Add code tags
  • Smygis
    New Member
    • Jun 2007
    • 126

    #2
    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
    Code:
    netElem = Visum.CreateNetElements()
    And then run:
    Code:
    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.

    Comment

    Working...