Surfer allows you to create a save custom colormaps (CLR) and levels files (LVL) in the user interface as described on the Colormap Editor help page. If you'd prefer to create a custom LVL file via automation, the script below will prompt the user for a name and location as well as the desired contour levels.
To run this script:
- Copy the script below, or download the attached BAS file: rainbow.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- 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.
- Click Script | Run to run the script.
*********
'============================================================================ ' RAINBOW.BAS ' ' This script creates a LVL file with colors ranging from ' red-yellow-green-cyan-blue. ' ' Contour lines are solid by default. For invisible contour lines, change ' Solid to Invisible in s1$. '============================================================================ Sub Main Dim contour(1000) header$ = "'Level Flags LColor LStyle LWidth FFGColor FBGColor FPattern FMode" q$ = Chr$(34) ' a double quote sp$ = Space$(1) ' a space s1$ = "0 " + q$ + "Black" + q$ + sp$ + q$ + "Solid" + q$ + " 0 " + q$ s3$ = q$ + sp$ + q$ + "White" + q$ + sp$ + q$ + "Solid" + q$ + " 2" form$ = s1$ + s2$ + s3$ lvlfile$=InputBox$( "Name of level file to create. Must include full file path and .lvl extension. For example: c:\temp\test.lvl") cmin=Val(InputBox$( "Minimum contour value: ")) cmax=Val(InputBox$( "Maximum contour value: ")) interval=Val(InputBox$( "Contour interval: ")) Open lvlfile$ For Output As #1 nlvls = (cmax - cmin) / interval - 1 ' was + 1, not -1 For i = 1 To nlvls contour(i) = cmin + i * interval ' was (i - 1) *, not i * Next end2 = Int(nlvls / 2) end1 = Int(end2 / 2) end3 = end2 + Int((nlvls - end2) / 2) Print #1, "LVL2" Print #1, header$ For i = 1 To end1 r = 0 b = 255 g = Int((255 / (end1 - 1)) * (i - 1)) red$ = LTrim$(Str$(r)) green$ = LTrim$(Str$(g)) blue$ = LTrim$(Str$(b)) Debug.Print contour(i);" ";red$;" "; green$;" "; blue$ Print #1, contour(i);" ";s1$+"R"+red$+" G"+green$+" B"+blue$+s3$ Next For i = end1 + 1 To end2 r = 0 g = 255 b = 255 - Int(255 / (end2 - end1) * (i - end1)) red$ = LTrim$(Str$(r)) green$ = LTrim$(Str$(g)) blue$ = LTrim$(Str$(b)) Debug.Print contour(i);" ";red$;" "; green$;" "; blue$ Print #1, contour(i);" ";s1$+"R"+red$+" G"+green$+" B"+blue$+s3$ Next For i = end2 + 1 To end3 b = 0 g = 255 r = Int(255 / (end3 - end2) * (i - end2)) red$ = LTrim$(Str$(r)) green$ = LTrim$(Str$(g)) blue$ = LTrim$(Str$(b)) Debug.Print contour(i);" ";red$;" "; green$;" "; blue$ Print #1, contour(i);" ";s1$+"R"+red$+" G"+green$+" B"+blue$+s3$ Next For i = end3 + 1 To nlvls r = 255 b = 0 g = 255 - Int(255 / (nlvls - end3) * (i - end3)) red$ = LTrim$(Str$(r)) green$ = LTrim$(Str$(g)) blue$ = LTrim$(Str$(b)) Debug.Print contour(i);" ";red$;" "; green$;" "; blue$ Print #1, contour(i);" ";s1$+"R"+red$+" G"+green$+" B"+blue$+s3$ Next Close #1 'LVL2 ' 52200 0 "Black" "Invisible" 0 "R0 G60 B255" "White" "Solid" 2 End Sub
Updated October 2021
Comments
0 comments
Please sign in to leave a comment.