Follow

How can I create a point cloud in Voxler via automation?

This article contains a sample script for loading a data file, adding a ScatterPlot to it, and changing all the properties of the ScatterPlot.

To run this script:

  1. Copy the script below, or click here to download the BAS file: ScatterPlotModule.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.
     

*********

'********************************************************************************************
' ScatterPlotModule.bas
' This script loads a data file and adds a scatter plot to it.
' It then changes all the properties of the scatter plot.
'********************************************************************************************

' 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 ("Options", "Defaults=1;EatWhitespace=1;Delimiter=Space,tab,comma,semicolon;TextQualifier=doublequote,quote")
  CommandApi.Option ("Filter", "dat")
  CommandApi.Option ("GuiEnabled", "False")
  CommandApi.Do()

 'Add a scatter plot
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("AutoConnect", "False")
  CommandApi.Option ("SourceModule", "GoldConcentration.dat")
  CommandApi.Option ("Type", "ScatterPlot")
  CommandApi.Do()

 'Connect the scatterplot and data modules
  CommandApi.Construct ("ConnectModules")
  CommandApi.Option ("SourceModule", "GoldConcentration.dat")
  CommandApi.Option ("TargetModule", "ScatterPlot")
  CommandApi.Do()

 'This section changes the symbol
 'This is a number between 0 and 30.  0 is the top marker in the list.  30 is the bottom marker in the list.
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "ScatterPlot")
  CommandApi.Option ("ScatterPlotMarker", "17")
  CommandApi.Do()

 'This changes the symbol size for symbol marker numbers 0 to 29.
 'This is a number between 0 and 2. 0 is the smallest, 2 is the largest sized symbol.
  CommandApi.Option ("ScatterPlotSizeMarker", "2")
  CommandApi.Do()

Wait (4)

 'This changes the symbol to the last symbol
  CommandApi.Option ("ScatterPlotMarker", "30")
 CommandApi.Do()

 'This changes the symbol size for marker number 30
 'This is a number between 0 and 48.  The larger the number, the larger the symbol.
  CommandApi.Option ("ScatterPlotSizePoint", "4.0")
  CommandApi.Do()

 'This changes the density of points to 50%
 'This is a number between 0 and 7.
 '0 = 100%, 1 = 50%, 2 = 33%, 3 = 25%, 4 = 20%, 5 = 10%, 6 = 5%, 7 = 1%
  CommandApi.Option ("ScatterPlotDensity", "3")
  CommandApi.Do()

 'This shows lines connecting the scatter points
  CommandApi.Option ("ScatterPlotShowLines", "True")
  CommandApi.Do()

 'This changes the line width of the scatter plot lines
  CommandApi.Option ("ScatterPlotLineWidth", "3")
  CommandApi.Do()

 'This changes the color method to Fixed
  CommandApi.Option ("ScatterPlotColorMethod", "0")
  CommandApi.Do()

 'This changes the color of the fixed scatter plot points
  CommandApi.Option ("ScatterPlotColorFixed", "Magenta")
  CommandApi.Do()

Wait (2)

 'Change the color method to By Data
  CommandApi.Option ("ScatterPlotColorMethod", "1")
  CommandApi.Do()

 'Change the color map being used to the "Rainbow" map
  CommandApi.Option ("ScatterPlotColorMap", "Rainbow")
  CommandApi.Do()

 'Change the color component, only available when the data set has more than one component
  CommandApi.Option ("ScatterPlotColorComponent", "2")
  CommandApi.Do()

 'Turn off the lines
 CommandApi.Option ("ScatterPlotShowLines", "False")
 CommandApi.Do()

 'Turn down point density
 CommandApi.Option ("ScatterPlotDensity", "7")
 CommandApi.Do()

 'Turn on labels
 CommandApi.Option ("ScatterPlotShowLabels", "True")
 CommandApi.Do()

 'Choose the first component as the label field.  We could use "X", "Y", "Z", "XYZ" or a named component here.
  CommandApi.Option ("ScatterPlotLabelField", "Component 1")
  CommandApi.Do()

 'Turn label leader lines on
  CommandApi.Option ("ScatterPlotShowLeaderLines", "True")
  CommandApi.Do()

 'Offset the labels
  CommandApi.Option ("ScatterPlotXOffset", "20")
  CommandApi.Do()
  CommandApi.Option ("ScatterPlotYOffset", "20")
  CommandApi.Do()

  'Color the labels by the component value.  Use "0" for fixed color, "1" for color by component.
  CommandApi.Option ("ScatterPlotLabelColorMethod", "1")
  CommandApi.Do()

 'Display the ScatterPlot legend
  CommandApi.Option ("ScatterPlotLegendEnable", "True")
  CommandApi.Do()

 'Change the legend orientation
 '0 is for horizontal, 1 is for vertical
  CommandApi.Option ("ScatterPlotLegendOrientation", "0")
  CommandApi.Do()

 'Change the legend X position
 'Ranges from 0-1
  CommandApi.Option ("ScatterPlotLegendXPos", "0.3")
  CommandApi.Do()

 'Change the legend Y position
 'Ranges from 0-1
  CommandApi.Option ("ScatterPlotLegendYPos", "0.9")
  CommandApi.Do()

 'Change the legend width
 'Ranges from 0-200
  CommandApi.Option ("ScatterPlotLegendWidth", "20")
  CommandApi.Do()

 'Change the legend length
 'Ranges from 0-1024
  CommandApi.Option ("ScatterPlotLegendLength", "400")
  CommandApi.Do()

 'Change the legend title
  CommandApi.Option ("ScatterPlotLegendTitle", "Legend Title")
  CommandApi.Do()

 'Change the legend title font size
 'Ranges from 4-72
  CommandApi.Option ("ScatterPlotLegendTitleHeight", "20")
  CommandApi.Do()

 'Change the number of labels displayed in a legend
  CommandApi.Option ("ScatterPlotLegendNumLabels", "3")
  CommandApi.Do()

 'Change the legend to use custom labels
  CommandApi.Option ("ScatterPlotLegendUseCustomLabels", "True")
  CommandApi.Do()

 'Set the custom labels for the legend
  CommandApi.Option ("ScatterPlotLegendCustomLabels", "1.7:low, 2.1:medium, 2.9:intermediate, 3.2:elevated, 3.7:high")
  CommandApi.Do()

 'Set the height for the legend labels
  CommandApi.Option ("ScatterPlotLegendLabelHeight", "8")
  CommandApi.Do()

 'Set the label format type for the legend
    CommandApi.Option("ScatterPlotLegendLabelFormatType", "0")
  CommandApi.Do()

 'Set the number of digits to display on the labels
    CommandApi.Option("ScatterPlotLegendLabelFormatNumDigits", "2")
  CommandApi.Do()

 'Set the legend label prefix
    CommandApi.Option("ScatterPlotLegendLabelFormatPrefix", "pre-")
  CommandApi.Do()

 'Set the legend label postfix
    CommandApi.Option("ScatterPlotLegendLabelFormatPostfix", "-post")
  CommandApi.Do()

 'Set the legend font
  CommandApi.Option ("ScatterPlotLegendFont", "Arial")
  CommandApi.Do()

 'Turn on or off antialiasing for the legend
  CommandApi.Option ("ScatterPlotLegendAntialias", "True")
  CommandApi.Do()

 'Set the line and text color for the legend
  CommandApi.Option ("ScatterPlotLegendFGColor", "Blue")
  CommandApi.Do()

 'Set the background color for the legend
  CommandApi.Option ("ScatterPlotLegendBGColor", "10% Gray")
  CommandApi.Do()

 'Turn on or off the display of the legend background
  CommandApi.Option ("ScatterPlotLegendShowBackground", "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.