CMG's (Computer Modeling Group's) simulation software requires a BNA header that does not match Surfer's export format. Surfer exports a BNA header with the z value in column A and an empty column in column B, but CMG expects the z value in column B and an empty column in column A. Rather than update the header information manually in a text editor, a script can be used to save time and ensure accuracy.
- In Windows Explorer, navigate to C:\Program Files\Golden Software\Surfer and double click on Scripter.exe to launch Scripter.
- Delete the existing two lines of script and copy/paste in this script:
Sub Main
'Initialize Surfer
Dim SurferApp, Wks, WksRangeA, WksRangeB As Object
Set SurferApp = CreateObject("Surfer.Application")
SurferApp.Visible = True 'Make Surfer visible
'Prompt the user for the name of the data file to process.
InFile = GetFilePath("","BNA", CurDir(), "Select data file", 0)
'Open BNA
Set Wks = SurferApp.Documents.Open(FileName:=InFile)
Set WksRangeA = Wks.Columns(Col1:=1, Col2:=1)
Set WksRangeB = Wks.Columns(Col1:=2, Col2:=2)
'Loop through rows
numrows = WksRangeA.RowCount
For i=1 To numrows
'If col B in row is empty, cut col A cell for that row and paste it into col B
If WksRangeB.Cells(i)="" Then
WksRangeA.Cells(i).Cut
WksRangeB.Cells(i).Paste
End If
Next
'Saves the BNA to the same name
Wks.Save
'Closes Surfer
SurferApp.Quit
End Sub - Click Script | Run.
- Choose your BNA file and click Open.
If you have multiple BNA files, you can update line 8 of this script to instead loop through BNA files in a certain directory.
Updated November 2021
Comments
Please sign in to leave a comment.