Surfer's grid volume report can be run and and the results called via automation but it is not currently possible to save the Grid Volume report directly. If you need to save the grid volume results for later use, a script like the one below can be used to write the results to a DAT file.
To run this script:
- Copy the script below, or download the attached BAS file: GridVolume.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.
*********
'GridVolume.bas calculates the volume and area of a grid file. 'The results are written to the worksheet and saved in a DAT file. '======================================= Sub Main 'Declare SurferApp as an object Dim SurferApp As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True '-------------User Input Required------------------------ 'Specifies the upper and lower surfaces. They can be a grid file or a constant Z value. UpperSurface = SurferApp.Path+"\samples\demogrid.grd" LowerSurface = 0 '------------------------------------------------------ 'Calculates the volume and area. This method does not display the report window Dim Results() As Double SurferApp.GridVolume(upper:=UpperSurface,lower:=LowerSurface, presults:=Results, showreport:=False) 'Create a new worksheet window Set Wks = SurferApp.Documents.Add(srfDocWks) 'Put the contents of pResults (the Grid Volume report) in the worksheet cells Wks.Cells("A1").Value = "Upper Surface:" Wks.Cells("B1").Value = UpperSurface Wks.Cells("A2").Value = "Lower Surface" Wks.Cells("B2").Value = LowerSurface Wks.Cells("A4").Value = "VOLUMES" Wks.Cells("A5").Value = "Trapezoidal Rule:" Wks.Cells("B5").Value = Results(srfGVTrapVol) Wks.Cells("A6").Value = "Simpson's Rule:" Wks.Cells("B6").Value = Results(srfGVSimpVol) Wks.Cells("A7").Value = "Simpson's 3/8 Rule:" Wks.Cells("B7").Value = Results(srfGVSimp38Vol) Wks.Cells("A9").Value = "CUT & FILL VOLUMES" Wks.Cells("A10").Value = "Positive Volume [Cut]:" Wks.Cells("B10").Value = Results(srfGVPosVol) Wks.Cells("A11").Value = "Negative Volume [Fill]:" Wks.Cells("B11").Value = Results(srfGVNegVol) Wks.Cells("A12").Value = "Cut minus Fill:" Wks.Cells("B12").Value = Results(srfGVPosVol) - Results(srfGVNegVol) Wks.Cells("A14").Value = "AREAS" Wks.Cells("A15").Value = "Positive Planar Area:" Wks.Cells("B15").Value = Results(srfGVPosPlanarArea) Wks.Cells("A16").Value = "Negative Planar Area:" Wks.Cells("B16").Value = Results(srfGVNegPlanarArea) Wks.Cells("A17").Value = "Blanked Planar Area:" Wks.Cells("B17").Value = Results(srfGVBlankedArea) Wks.Cells("A18").Value = "Total Planar Area" Wks.Cells("B18").Value = Results(srfGVPosPlanarArea)+ Results(srfGVNegPlanarArea) + Results(srfGVBlankedArea) Wks.Cells("A20").Value = "Positive Surface Area:" Wks.Cells("B20").Value = Results(srfGVPosArea) Wks.Cells("A21").Value = "Negative Surface Area:" Wks.Cells("B21").Value = Results(srfGVNegArea) 'Saves the worksheet Wks.SaveAs("C:\temp\VolumeReport.dat") End Sub
Updated November 2021
Comments
Please sign in to leave a comment.