Follow

How can I interpolate data in Voxler using automation?

This article contains a sample script for loading a data file, adding a Gridder module to it, and changing all the properties of the Gridder module. An Isosurface and contour maps are connected to the Gridder to show the changes.

To run this script:

  1. Copy the script below, or click here to download the BAS file: GridderModule.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Voxler 4\Scripter.
  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.
     

*********

'********************************************************************************************
' GridderModule.bas
' This script loads a data file and adds a gridder module to it.
' It then changes all the properties of the gridder module.
' An isosurface and contour maps are connected to the gridder to show the changes.
'********************************************************************************************

' If Voxler is running, retrieve the current instance of Voxler.  Otherwise,
' create a new instance of Voxler.
Function VoxlerApplication()
   On Error Resume Next
   Set VoxlerApplication = GetObject(, "Voxler.Application")
   If Err.Number <> 0 Then
      Set VoxlerApplication = CreateObject("Voxler.Application")
   End If
   On Error GoTo 0
End Function

Sub Main
 'Retrieve running instance of Voxler or create a new instance of Voxler
  Dim VoxlerApp As Object
  Set VoxlerApp = VoxlerApplication()

 'Make Voxler visible
  VoxlerApp.Visible = True

 'Access CommandApi
  Set CommandApi = VoxlerApp.CommandApi

 'Create a new Voxler document
  CommandApi.Construct ("New")
  CommandApi.DoOnce()

 'Load the data file
  CommandApi.Construct("Import")
  CommandApi.Option ("Path", VoxlerApp.Path+"\Samples\GoldConcentration.dat")
  CommandApi.Option ("Filter", "dat")
  CommandApi.Option ("Options", "Defaults=1;EatWhitespace=1;Delimiter=Space,tab,comma,semicolon;TextQualifier=doublequote,quote")
  CommandApi.Option ("GuiEnabled", "False")
  CommandApi.Do()

 'Add a gridder module
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "GoldConcentration.dat")
  CommandApi.Option ("Type", "Gridder")
  CommandApi.Do()

 'Grid the data
  CommandApi.Construct("ModifyModule")
  CommandApi.Option("Module","Gridder")
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

 'Add a contours module
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Gridder")
  CommandApi.Option ("Type", "Contours")
  CommandApi.Do()

 'Add an isosurface module
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Gridder")
  CommandApi.Option ("Type", "Isosurface")
  CommandApi.Do()

 'Change which component is being gridded
 'Value is 1, 2, 3... indicating which component
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Gridder")
  CommandApi.Option ("Gridder3Component", "1")
  CommandApi.Do()

 'Calculate default values based on component input data
  CommandApi.Option ("Gridder3Auto", "True")
  CommandApi.Do()

'****Change the gridding geometry parameters

 'Change the X min value for the output grid
  CommandApi.Option ("Gridder3XMin", "-10")
  CommandApi.Do()

 'Change the X max value for the output grid
  CommandApi.Option ("Gridder3XMax", "110")
  CommandApi.Do()

 'Change the Y min value for the output grid
  CommandApi.Option ("Gridder3YMin", "0")
  CommandApi.Do()

 'Change the Y max value for the output grid
  CommandApi.Option ("Gridder3YMax", "100")
  CommandApi.Do()

 'Change the Z min value for the output grid
  CommandApi.Option ("Gridder3ZMin", "20")
  CommandApi.Do()

 'Change the Z max value for the output grid
  CommandApi.Option ("Gridder3ZMax", "80")
  CommandApi.Do()

 'Change the number of nodes in the X direction for the output grid
  CommandApi.Option ("Gridder3XNum", "40")
  CommandApi.Do()

 'Change the number of nodes in the Y direction for the output grid
  CommandApi.Option ("Gridder3YNum", "50")
  CommandApi.Do()

 'Change the number of nodes in the Z direction for the output grid
  CommandApi.Option ("Gridder3ZNum", "20")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (4)

 'Change the X spacing for the output grid
  CommandApi.Option ("Gridder3XSpacing", "2")
  CommandApi.Do()

 'Change the Y spacing for the output grid
  CommandApi.Option ("Gridder3YSpacing", "2")
  CommandApi.Do()

 'Change the Z spacing for the output grid
  CommandApi.Option ("Gridder3ZSpacing", "2")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (2)

'****Change the gridding search parameters

 'Change the search type to use for the output grid
 'Value is 0, 1, 2, 3 for All Data, Simple, Anisotropic, or General
  CommandApi.Option ("Gridder3Search", "2")
  CommandApi.Do()

 'Change the minimum number of data in the search neighborhood
 'Only available if Gridder3Search = 1, 2, 3
  CommandApi.Option ("Gridder3SearchMin", "2")
  CommandApi.Do()

 'Change the maximum number of data in the search neighborhood
 'Only available if Gridder3Search = 1, 2, 3
  CommandApi.Option ("Gridder3SearchMax", "35")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (2)

 'Change the search type to use for the output grid
  CommandApi.Option ("Gridder3Search", "1")
  CommandApi.Do()

 'Change the maximum number of data in the search neighborhood
 'Only available if Gridder3Search = 1
  CommandApi.Option ("Gridder3SearchRadius", "10")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (4)

 'Change the search type to use for the output grid
  CommandApi.Option ("Gridder3Search", "2")
  CommandApi.Do()

 'Change the length of the X Axis for the search ellipse to use for the output grid
 'Option only available when Gridder3Search = 2
  CommandApi.Option ("Gridder3SearchXLength", "50")
  CommandApi.Do()

 'Change the length of the Y Axis for the search ellipse to use for the output grid
 'Option only available when Gridder3Search = 2
  CommandApi.Option ("Gridder3SearchYLength", "50")
  CommandApi.Do()

 'Change the length of the Z Axis for the search ellipse to use for the output grid
 'Option only available when Gridder3Search = 2
  CommandApi.Option ("Gridder3SearchZLength", "50")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (4)

 'Change the search type to use for the output grid
  CommandApi.Option ("Gridder3Search", "3")
  CommandApi.Do()

 'Change the X coordinate of the first semi-axis for the general search ellipse
 'Option only available when Gridder3Search = 3
  CommandApi.Option ("Gridder3SearchFirstSemiAxisX", "50")
  CommandApi.Do()

 'Change the Y coordinate of the first semi-axis for the general search ellipse
 'Option only available when Gridder3Search = 3
  CommandApi.Option ("Gridder3SearchFirstSemiAxisY", "20")
  CommandApi.Do()

 'Change the Z coordinate of the first semi-axis for the general search ellipse
 'Option only available when Gridder3Search = 3
  CommandApi.Option ("Gridder3SearchFirstSemiAxisZ", "10")
  CommandApi.Do()

 'Change the X coordinate of the second semi-axis for the general search ellipse
 'Option only available when Gridder3Search = 3
  CommandApi.Option ("Gridder3SearchSecondSemiAxisX", "10")
  CommandApi.Do()

 'Change the Y coordinate of the Second semi-axis for the general search ellipse
 'Option only available when Gridder3Search = 3
  CommandApi.Option ("Gridder3SearchSecondSemiAxisY", "10")
  CommandApi.Do()

 'Change the Z coordinate of the Second semi-axis for the general search ellipse
 'Option only available when Gridder3Search = 3
  CommandApi.Option ("Gridder3SearchSecondSemiAxisZ", "70")
  CommandApi.Do()

 'Change the X coordinate of the Third semi-axis for the general search ellipse
 'Option only available when Gridder3Search = 3
  CommandApi.Option ("Gridder3SearchThirdSemiAxisX", "40")
  CommandApi.Do()

 'Change the Y coordinate of the Third semi-axis for the general search ellipse
 'Option only available when Gridder3Search = 3
  CommandApi.Option ("Gridder3SearchThirdSemiAxisY", "5")
  CommandApi.Do()

 'Change the Z coordinate of the Third semi-axis for the general search ellipse
 'Option only available when Gridder3Search = 3
  CommandApi.Option ("Gridder3SearchThirdSemiAxisZ", "75")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (4)

'****Reset to default values

 'Calculate default values based on component input data
  CommandApi.Option ("Gridder3Auto", "True")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

'****Change the gridding interpolation method parameters

 'Set the gridding method for the output grid file
 'Value is 0, 1, or 2 for Data Metric, Inverse Distance, or Local Polynomial
  CommandApi.Option ("Gridder3Method", "0")
  CommandApi.Do()

 'Change the data metric type for the data metric gridding method
 'Gridder3Method must be 0
 'Value is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, or 20
 'For 0=Minimum, 1=Lower Quartile, 2=Median, 3=Upper Quartile, 4=Maximum, 5=Range, 6=Midrange, 7=Inter-quartile Range,
 '8=Mean, 9=Standard Deviation, 10=Variance, 11=Coefficient of Variation, 12=Sum, 13=Median Absolute Deviation,
 '14=Root Mean Square, 15=Count, 16=Density, 17=Nearest, 18=Farthest, 19=Median Distance, or 20=Average Distance
  CommandApi.Option ("Gridder3Metric", "15")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (4)

 'Set the gridding method for the output grid file
 'Value is 0, 1, or 2 for Data Metric, Inverse Distance, or Local Polynomial
  CommandApi.Option ("Gridder3Method", "1")
  CommandApi.Do()

 'Set the anisotropy type for the Inverse Distance Gridding method
 'Value is 0, 1, or 2 for Isotropic, Anisotropic, or General
 'Option is only available when Gridder3Method = 1
  CommandApi.Option ("Gridder3Aniso", "0")
  CommandApi.Do()

 'Set the exponent in the inverse distance weighting function
 'Option only available when Gridder3Method = 1
  CommandApi.Option ("Gridder3DistancePower", "2.4")
  CommandApi.Do()

 'Set the interpolation smoothing factor in the inverse distance weighting function
  CommandApi.Option ("Gridder3DistanceSmooth", "4.1")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (4)

 'Set the anisotropy type for the Inverse Distance Gridding method
 'Value is 0, 1, or 2 for Isotropic, Anisotropic, or General
 'Option is only available when Gridder3Method = 1
  CommandApi.Option ("Gridder3Aniso", "1")
  CommandApi.Do()

 'Set the anisotropic scale length along the X axis
 'Option only available when Gridder3Aniso = 1
  CommandApi.Option ("Gridder3AnisoXLength", "50")
  CommandApi.Do()

 'Set the anisotropic scale length along the Y axis
 'Option only available when Gridder3Aniso = 1
  CommandApi.Option ("Gridder3AnisoYLength", "124.7")
  CommandApi.Do()

 'Set the anisotropic scale length along the Z axis
 'Option only available when Gridder3Aniso = 1
  CommandApi.Option ("Gridder3AnisoZLength", "300")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (4)

 'Set the anisotropy type for the Inverse Distance Gridding method
 'Value is 0, 1, or 2 for Isotropic, Anisotropic, or General
 'Option is only available when Gridder3Method = 1
  CommandApi.Option ("Gridder3Aniso", "2")
  CommandApi.Do()

 'Set the X coordinate of the first semi-axis for the general anisotropy
 'Option only available when Gridder3Aniso = 2
  CommandApi.Option ("Gridder3AnisoFirstSemiAxisX", "50")
  CommandApi.Do()

 'Set the Y coordinate of the first semi-axis for the general anisotropy
 'Option only available when Gridder3Aniso = 2
  CommandApi.Option ("Gridder3AnisoFirstSemiAxisY", "50")
  CommandApi.Do()

 'Set the Z coordinate of the first semi-axis for the general anisotropy
 'Option only available when Gridder3Aniso = 2
  CommandApi.Option ("Gridder3AnisoFirstSemiAxisZ", "50")
  CommandApi.Do()

 'Set the X coordinate of the Second semi-axis for the general anisotropy
 'Option only available when Gridder3Aniso = 2
  CommandApi.Option ("Gridder3AnisoSecondSemiAxisX", "0")
  CommandApi.Do()

 'Set the Y coordinate of the Second semi-axis for the general anisotropy
 'Option only available when Gridder3Aniso = 2
  CommandApi.Option ("Gridder3AnisoSecondSemiAxisY", "75")
  CommandApi.Do()

 'Set the Z coordinate of the Second semi-axis for the general anisotropy
 'Option only available when Gridder3Aniso = 2
  CommandApi.Option ("Gridder3AnisoSecondSemiAxisZ", "-50")
  CommandApi.Do()

 'Set the X coordinate of the Third semi-axis for the general anisotropy
 'Option only available when Gridder3Aniso = 2
  CommandApi.Option ("Gridder3AnisoThirdSemiAxisX", "25")
  CommandApi.Do()

 'Set the Y coordinate of the Third semi-axis for the general anisotropy
 'Option only available when Gridder3Aniso = 2
  CommandApi.Option ("Gridder3AnisoThirdSemiAxisY", "-45")
  CommandApi.Do()

 'Set the Z coordinate of the Third semi-axis for the general anisotropy
 'Option only available when Gridder3Aniso = 2
  CommandApi.Option ("Gridder3AnisoThirdSemiAxisZ", "100")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

Wait (4)

 'Set the gridding method for the output grid file
 'Value is 0, 1, or 2 for Data Metric, Inverse Distance, or Local Polynomial
  CommandApi.Option ("Gridder3Method", "2")
  CommandApi.Do()

 'Set the gridding method for the output grid file
 'Value is an integer, indicating the local polynomial order for the interpolation
  CommandApi.Option ("Gridder3PolyOrder", "3")
  CommandApi.Do()

 'Set the gridding method for the output grid file
 'Value is an integer, indicating the exponent in the weighting function
  CommandApi.Option ("Gridder3PolyPower", "4")
  CommandApi.Do()

 'Grid the data
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

End Sub

 

Updated November 3, 2016

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.