PTV Visum - Frequently Asked Questions (FAQs)

(#VIS14889)

Wie kann man über COM eine Spinne (IV/ÖV) erstellen und die ÖV-Wegeliste auslesen?

1) Spinne erstellen:
Set aStopPoint = Visum.Net.StopPoints.ItemByKey(30)
Set aNetElms = Visum.CreateNetElements
aNetElms.Add aStopPoint
Set aFlowBundle = Visum.Net.FlowBundle
aFlowBundle.Clear
aFlowBundle.DemandSegments = 'P'
aFlowBundle.Execute aNetElms

2) ÖV-Wegeliste erstellen:
Set aPuTPathList = Visum.Lists.CreatePuTPathList
aPuTPathList.SetObjects 0, 'P', routeFilter_filterFlowBundleRoutes
aPuTPathList.AddKeyColumns
aPuTPathList.AddColumn 'JourneyTime'
aPuTPathList.AddColumn 'Dep'
aPuTPathList.AddColumn 'Arr'
aPuTPathList.Show

3) ÖV-Wegeliste als Array auslesen:
aPuTPathListArray = aPuTPathList.SaveToArray
For aPath = 0 To UBound(aPuTPathListArray)
aStr = ''
For anAttr = 0 To aPuTPathList.NumColumns - 1
aStr = aStr & aPuTPathListArray(aPath, anAttr) & ' '
Next anAttr
Debug.Print Trim(aStr)
Next aPath

4) Ein Beispiel für Python zu wie man eine Spinne mit beschränkten Verkehrsarten/Fahrtgastarten mit einem ActivityTypeSet und CreateCondition mit Complement = True zum Kodieren von 'Und dann nicht' erstellt:

aFlowBundle = Visum.Net.FlowBundle
aFlowBundle.Clear()
aFlowBundle.DemandSegments = 'P'
aZone = Visum.Net.Zones.ItemByKey(100)
aLink1 = Visum.Net.Links.ItemByKey(10, 11)
aLink2 = Visum.Net.Links.ItemByKey(20, 21)
anActivityTypeSet = aFlowBundle.CreateActivityTypeSet()
anActivityTypeSet.Add (1)
aNetElms = Visum.CreateNetElements()
aNetElms.Add(Visum.Net.TSystems.ItemByKey('B'))
aFlowBundle.CreateConditionWithRestrictedSupply(aZone, aNetElms, False, anActivityTypeSet)
aFlowBundle.CreateNewGroup()
aFlowBundle.CreateCondition(aLink1, anActivityTypeSet, False)
aFlowBundle.CreateCondition(aLink2, anActivityTypeSet, True)
aFlowBundle.ExecuteCurrentConditions()

Ein Beispiel zu wie man diesen Beispielkode in der Visum Python console nachvollziehen könnte:


5) Ein Beispiel für IV:

Set aMainZone = Visum.Net.MainZones.ItemByKey(1)
Set aFlowBundle = Visum.Net.FlowBundle
aFlowBundle.Clear
aFlowBundle.DemandSegments = 'C'

Set anActivityTypeSet = aFlowBundle.CreateActivityTypeSet
anActivityTypeSet.Add 2 ' 2 for destination activity trips

aFlowBundle.CreateCondition aMainZone, anActivityTypeSet
aFlowBundle.ExecuteCurrentConditions

6) Ein Beispiel für den ÖV für 'Linien auswählen' und 'Auswahl der Verkehrsarten' (Quellverkehr/Zielverkehr):

Bemerkungen:
- Die Linienauswahl macht hier von einem Filter gebrauch, weil diese Funktionalität im Dialog 'Grafikwerkzeuge (Spinne)' in der COM-Schnittstelle nicht abgebildet ist.
- Sobald der Linieinfilter aktiv ist, kann die Methode
aFlowBundle.CreateConditionActiveLines
ein IRouteTrafficTypeSet-Objekt, das die Verkehrsarten kodiert, verwenden.

Sub TestFlowBundleWithLineSelection()
Dim Visum As New VISUMLIB.Visum
Dim aNetElms As VISUMLIB.INetElements
Dim aFlowBundle As VISUMLIB.IFlowBundle
Dim anRouteTrafficTypeSet As VISUMLIB.IRouteTrafficTypeSet

Visum.IO.LoadVersion Application.ActiveWorkbook.Path & cMyVersionFileIn

Set aNetElms = Visum.CreateNetElements
aNetElms.Add Visum.Net.Lines.ItemByKey('004')

Set aFlowBundle = Visum.Net.FlowBundle
aFlowBundle.Clear

Set anRouteTrafficTypeSet = aFlowBundle.CreateRouteTrafficTypeSet
anRouteTrafficTypeSet.Add 2
anRouteTrafficTypeSet.Add 4

Visum.Filters.LineGroupFilter.Init
'Visum.Filters.LineGroupFilter.LineFilter.AddCondition 'OP_NONE', False, 'NAME', 'EqualVal', '004' 'Alternative way.
Visum.Filters.LineGroupFilter.LineFilter.SetSelection aNetElms
Visum.Filters.LineGroupFilter.LineFilter.UseSelection = True

Visum.Filters.LineGroupFilter.LineFilter.UseFilter = True
Visum.Filters.LineGroupFilter.UseFilterForLines = True

aFlowBundle.DemandSegments = 'PuT'
aFlowBundle.CreateConditionActiveLines anRouteTrafficTypeSet
aFlowBundle.ExecuteCurrentConditions

Set Visum = Nothing

End Sub

7) Ein Beispiel für zwei Haltestellen und eine Linie:

Sub TestFlowBundleWithStopPointAndLineSelection()
Dim Visum As New VISUMLIB.Visum
Dim aNetElms As VISUMLIB.INetElements
Dim aFlowBundle As VISUMLIB.IFlowBundle
Dim anActivityTypeSet1 As VISUMLIB.IActivityTypeSet
Dim anActivityTypeSet2 As VISUMLIB.IActivityTypeSet
Dim aStopPoint1 As VISUMLIB.IStopPoint
Dim aStopPoint2 As VISUMLIB.IStopPoint

Visum.IO.LoadVersion Application.ActiveWorkbook.Path & cMyVersionFileIn

Set aFlowBundle = Visum.Net.FlowBundle
aFlowBundle.Clear
aFlowBundle.DemandSegments = 'PuT'

Set aStopPoint1 = Visum.Net.StopPoints.ItemByKey('100030')
Set aStopPoint2 = Visum.Net.StopPoints.ItemByKey('100002')

Set anActivityTypeSet1 = aFlowBundle.CreateActivityTypeSet
anActivityTypeSet1.Add 1 ' Origin traffic
'anActivityTypeSet1.Add 2 ' Destination traffic
anActivityTypeSet1.Add 4 ' Boarding passengers
'anActivityTypeSet1.Add 8 ' Alighting passengers
anActivityTypeSet1.Add 16 ' Transfers
anActivityTypeSet1.Add 32 ' PassThroughStop
anActivityTypeSet1.Add 64 ' PassThroughNoStop

Debug.Print anActivityTypeSet1.GetActivityTypeSet

Set anActivityTypeSet2 = aFlowBundle.CreateActivityTypeSet
'anActivityTypeSet2.Add 1 ' Origin traffic
anActivityTypeSet2.Add 2 ' Destination traffic
'anActivityTypeSet2.Add 4 ' Boarding passengers
anActivityTypeSet2.Add 8 ' Alighting passengers
anActivityTypeSet2.Add 16 ' Transfers
anActivityTypeSet2.Add 32 ' PassThroughStop
anActivityTypeSet2.Add 64 ' PassThroughNoStop

Debug.Print anActivityTypeSet2.GetActivityTypeSet

Set aNetElms = Visum.CreateNetElements
aNetElms.Add Visum.Net.Lines.ItemByKey('004')
aFlowBundle.CreateConditionWithRestrictedSupply aStopPoint1, aNetElms, False, anActivityTypeSet1
aFlowBundle.CreateConditionWithRestrictedSupply aStopPoint2, aNetElms, False, anActivityTypeSet2
aFlowBundle.ExecuteCurrentConditions

Set Visum = Nothing

End Sub




Ausführbare Beispiele als VBA:
http://vision-traffic.ptvgroup.com/faq-files/PTV_COM_Readout_FlowbundlePaths_from_List_PuTPaths.zip
c:\Users\Public\Documents\PTV Vision\PTV Visum 16\COM\Examples_ComDocu\VBA\FlowBundleAnalysis.xls

In Python:
c:\Users\Public\Documents\PTV Vision\PTV Visum 16\COM\Examples_ComDocu\Python\FlowbundleAnalysis.py