How can I draw text in Voxler via automation?

This article contains a sample script for opening an existing VOXB file and adding a Text module, then changing the properties of the Text module.

To run this script:

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


' TextModule.bas
' This script opens an existing VOXB file and adds a text module.
' It then changes all the properties of the text.

' 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

 'Open an existing file
  CommandApi.Construct ("Open")
  CommandApi.Option ("Path", VoxlerApp.Path+"\Samples\Gold (ScatterPlot).voxb")

 'Add a text module
  CommandApi.Option ("Type", "Text")

 'Change the text that is displayed in the text to two lines of text
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Text")
  CommandApi.Option ("TextText", "text in the map coordinates" + vbCrLf + "Multiple lines")

 'Change the text X position
 'This positions the location of the text in the X map coordinates.
  CommandApi.Option ("TextXPos", "50")

 'Change the text Y position
 'This positions the location of the text in the Y map coordinates
  CommandApi.Option ("TextYPos", "50")

 'Change the text Z position
 'This positions the location of the text in the Z map coordinates
  CommandApi.Option ("TextZPos", "50")

 'Change the text multiple line justification
 'This is 0, 1, or 2. 0 is left. 1 is center. 2 is right.
  CommandApi.Option ("TextJustification", "1")

 'Change the text size
 'This is between 4 and 72
  CommandApi.Option ("TextSize", "20")

 'Change the text color
  CommandApi.Option ("TextColor", "Plum")

 'Change the text font to Times New Roman
  CommandApi.Option ("TextFont", "Times New Roman")

End Sub


Updated November 3, 2016

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


Please sign in to leave a comment.