Search code examples
pythonvbacomattributeerror

Python AttributeError when using a specific type of object


I have a VBA script that i run from within a software called Visum. This script calculates some stuff and returns some results to the software. What I'm trying to do is to "convert" this script to Python, but I'm having problem with this part of the code:
VBA (works, using Visum library):

Dim PathList_0 As IPrTPathLinkList
Set PathList_0 = Visum.Lists.CreatePrTPathLinkList

Set DSeg = Visum.Net.DemandSegments.ItemByKey(Segmento_Demanda)
PathList_0.SetObjects newDemandSegOrPathSet:=DSeg, PathTypeSelection:=routeFilter_filterFromZoneFilter, ListFormat:=listFormat_databaseWithoutHeadLine, zone:=All
PathList_0.AddColumn ("OrigZoneNo")
aPath_0 = PathList_0.SaveToArray()

Python (doesn't work... according to the software manual, it's not necessary to import any 'Visum' module, since I'm running this script from within the software):

PathList_0 = Visum.ListsCreatePrTPathLinkList #ERROR

DSeg = Visum.NetDemandSegments.ItemByKey(Segmento_Demanda)
PathList_0.SetObjects("All", DSeg, "routeFilter_filterFromZoneFilter", False, "listFormat_databaseWithoutHeadLine")
PathList_0.AddColumn("OrigZoneNo")
aPath_0 = PathList_0.SaveToArray()

When I run the VBA script, it works. But when I run the Python script, it returns an AttributeError:

Script Error window

I've read some similar questions about AttributeError, but I couldn't find useful information for this specific situation. I've also read dynamic.py and pyscript.py, but since I'm not an experienced programmer, I couldn't find out the problem.

My Python version is compatible with the the Visum software (I've checked on it).

I'm asking this question because I think it may be related with some mistake I made when "converting" to Python. Can anyone help me with this error?


Solution

  • It is just a typo:

    PathList_0 = Visum.ListsCreatePrTPathLinkList
    

    should be

    PathList_0 = Visum.Lists.CreatePrTPathLinkList
    

    note the dot after Lists