﻿'Loop-ExportGIF.bas creates a 3D surface map, rotates it by 5 degrees,
'and exports a GIF for each rotation.
'You can change the grid file, the rotation increment, and the output file path.

Sub Main

'Declare the variable that will reference the application
    Dim SurferApp As Object
    Set SurferApp = CreateObject("Surfer.Application")
    SurferApp.Visible = True

'Declares Plot as an object
    Dim Plot As Object
    Set Plot = SurferApp.Documents.Add

'Creates surface map and assigns the map frame to the variable "MapFrame"
	Dim MapFrame1 As Object
    Set MapFrame1 = Plot.Shapes.AddSurface(GridFileName:=SurferApp.Path+"\samples\demogrid.grd")

'Sets the initial tilt of the map
	MapFrame1.ViewTilt = 16

'Starts the loop for 0-355 with a step value of 5
	For i=0 To 355 Step 5

		'Sets the 3D rotation, in degrees
   			 MapFrame1.ViewRotation = i

		'Exports the map frame to a GIF file
			 Plot.Export(FileName:="C:\temp\3d surface"+i+".gif")

'Goes to the next i value
	Next i


End Sub
