PTV Visum - Frequently Asked Questions (FAQs)

  • Please make sure the page has finished loading before you browse the FAQ list.


How to create a flow bundle (PrT/PuT) and read out PuT path list by using COM?

1) Create a flow bundle:
Set aStopPoint = Visum.Net.StopPoints.ItemByKey(30)
Set aNetElms = Visum.CreateNetElements
aNetElms.Add aStopPoint
Set aFlowBundle = Visum.Net.FlowBundle
aFlowBundle.DemandSegments = 'P'
aFlowBundle.Execute aNetElms

2) Create a PuT path list:
Set aPuTPathList = Visum.Lists.CreatePuTPathList
aPuTPathList.SetObjects 0, 'P', routeFilter_filterFlowBundleRoutes
aPuTPathList.AddColumn 'JourneyTime'
aPuTPathList.AddColumn 'Dep'
aPuTPathList.AddColumn 'Arr'

3) Read out the PuT path list:
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) An example for Python on how to create a flow bundle with restricted traffic types/passenger types using an ActivityTypeSet, and use CreateCondition with Complement = True to code 'And then not':

aFlowBundle = Visum.Net.FlowBundle
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()
aFlowBundle.CreateConditionWithRestrictedSupply(aZone, aNetElms, False, anActivityTypeSet)
aFlowBundle.CreateCondition(aLink1, anActivityTypeSet, False)
aFlowBundle.CreateCondition(aLink2, anActivityTypeSet, True)

An example on how to check this example code in the Visum Python console:

5) An example for PrT:

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

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

aFlowBundle.CreateCondition aMainZone, anActivityTypeSet

6) An example for PuT using a 'Line selection' and 'Selection of traffic types' (Origin demand/Destination demand)?

- The line selection needs to be set using a filter, as this functionality of the dialog 'Graphics tools (Flow bundle)' is not available in the COM interface.
- Once the line filter is active, the method
can catch an IRouteTrafficTypeSet object, coding the Traffic types.

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

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

'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

Set Visum = Nothing

End Sub

7) An example on two stops and a line:

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.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

Set Visum = Nothing

End Sub

Executable examples in VBA:
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\