The previous section uses a simple loop to create each point in AutoCAD from each marker in Maxsurf. If we wanted a more complicated program, where the marker data was being used several times, we could use an array to hold all the marker data. Holding all the Marker data in an array means we only have to call the data from Maxsurf once.
The flow diagram for the procedure using arrays looks like this:

Figure 19 Flow chart for using an array to add AutoCAD points
There is no speed advantage in using an array over the previous method for this example. The advantage however is in being able to expand the program to use the Marker data multiple times, without calling Maxsurf every time. We could easily expand the program to export the marker data to Excel and Word without a significant increase in execution time.
The full code for importing the markers using an array is as follows. Note that the array CoOrdArray is a Variant (will take any data type) and is used to store the array CoOrd that holds the coordinates for one marker. So the three coordinates for each marker are stored in one dimension of CoOrdArray
Public Sub ImportMarkersArray()
'sTime is the start time for the code execution
sTime = VBA.Timer
Dim msDesign As Maxsurf.Design 'Creates a shortcut to the design object
Dim CoOrd(2) As Double 'This will be the coordinates of the marker point
Dim CoOrdArray() As Variant
Set msDesign = msApp.Design 'Defines the term msDesign
ThisDrawing.SetVariable "PDMODE", 32 'This sets the style of the AutoCAD point
ThisDrawing.SetVariable "PDSIZE", 1 'This sets the size of the AutoCAD point
msTime = 0
slTimeIn = 0
'the marker count is used several times, so we only find it once
count = msDesign.markers.count
ReDim CoOrdArray(1, count)
For i = 1 To count 'msDesign.markers.count
'msTimeIn is the time that we call Maxsurf
msTimeIn = VBA.Timer
CoOrd(0) = msDesign.markers(i).Position
CoOrd(1) = msDesign.markers(i).Offset
CoOrd(2) = msDesign.markers(i).Height
CoOrdArray(0, i) = CoOrd
CoOrdArray(1, i) = msDesign.markers(i).Station
'msTime is the total time spent in Maxsurf
'It is appended on every iteration
msTime = msTime + VBA.Timer - msTimeIn
Next
slTimeIn = VBA.Timer
For J = 1 To count
'This calls a subprocedure to set the layer for the marker
'Requires the first part of the layer name (String) and the ID number
Call SetLayer("Maxsurf Markers", CoOrdArray(1, J))
ThisDrawing.Application.ActiveDocument.ModelSpace.AddPoint (CoOrdArray(0, J))
Next
slTime = VBA.Timer - slTimeIn
ZoomAll
'redraw the screen so that circles are circles again
ThisDrawing.Regen acActiveViewport
'Returning the active layer to "0" makes deleting layers easier
ThisDrawing.activeLayer = ThisDrawing.Layers("0")
fTime = VBA.Timer - sTime
'The command vbCrLf puts a carriage return, line feed in the MsgBox
MsgBox "Total Execution Time was " & fTime & " Seconds" & vbCrLf & "Total Time Calling Maxsurf " & msTime & " Seconds" & vbCrLf & "Total Time setting layers and adding points " & slTime & " Seconds"
End Sub