Create a movie of a rotating 3D surface via Surfer automation

Surfer's 3D View supports the creations of Fly-Through recordings as well as 3D PDF export as described in the articles below:

Alternatively, you can create a movie of a rotating 3D surface by exporting a GIF while you rotate the surface in small increments, and then you can import all of the GIFs into any number of free online tools to create a movie. This article contains a sample script for creating a 3D surface map and rotating it in 5 degree increments, exporting a GIF after each rotation. 

To run this script:

  1. Copy the script below, or download the attached BAS file: Loop-ExportGIF.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  6. Click Script | Run to run the script.
     

*********

'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

 

Updated December 2021

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.