Follow

How do I load an existing VOXB file and add axes in Voxler via automation?

This article contains a Voxler sample script that shows how to load an existing VOXB file and adds axes.It then changes all the properties of the axes.

 

To run this script:

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

*********

 

'********************************************************************************************
' AxesModule.bas
' This script loads an existing VOXB file and adds axes.
' It then changes all the properties of the axes.
'
'                                    -by SKP 4/2010
'
'********************************************************************************************

' 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()

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

 'Add axes
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "Axes")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "ScatterPlot")
  CommandApi.Do()

 'Show X Axis
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Axes")
  CommandApi.Option ("AxesXAxisShow", "True")
  CommandApi.Do()
  'Change the X Axis properties
	 'Change the X Axis color
  		CommandApi.Option ("AxesXAxisColor", "light green")
  		CommandApi.Do()
	 'Change the X Axis start value
  		CommandApi.Option ("AxesXAxisBeg", "20")
  		CommandApi.Do()
	 'Change the X Axis ending value
  		CommandApi.Option ("AxesXAxisEnd", "110")
  		CommandApi.Do()
	 'Change the value that the X Axis crosses the Y axis
  		CommandApi.Option ("AxesXAxisCross1", "0")
  		CommandApi.Do()
	 'Change the value that the X Axis crosses the Z axis
  		CommandApi.Option ("AxesXAxisCross2", "50")
  		CommandApi.Do()
	 'Change the angle where the axis labels are located
  		CommandApi.Option ("AxesXAxisPlane", "45")
  		CommandApi.Do()
	 'Assign a title to the X Axis
  		CommandApi.Option ("AxesXAxisTitle", "X Axis Title")
  		CommandApi.Do()
	 'Show the X Axis labels
  		CommandApi.Option ("AxesXAxisShowLabels", "True")
  		CommandApi.Do()
	 'Flip the X Axis labels in the horizontal direction
  		CommandApi.Option ("AxesXAxisFlipLabelsX", "True")
  		CommandApi.Do()
	 'Flip the X Axis labels in the vertical direction
  		CommandApi.Option ("AxesXAxisFlipLabelsY", "True")
  		CommandApi.Do()
	 'Change the starting X Axis label
  		CommandApi.Option ("AxesXAxisLabelBeg", "30")
  		CommandApi.Do()
	 'Change the ending X Axis label
  		CommandApi.Option ("AxesXAxisLabelEnd", "85")
  		CommandApi.Do()
	 'Change the X axis label increment
  		CommandApi.Option ("AxesXAxisLabelInc", "5")
  		CommandApi.Do()
	 'Change the X Axis label angle
  		CommandApi.Option ("AxesXAxisLabelAngle", "75")
  		CommandApi.Do()
	 'Change the number of ticks between major ticks
  		CommandApi.Option ("AxesXAxisTicksPerLabel", "2")
  		CommandApi.Do()
	 'Change the label format
  		CommandApi.Option ("AxesXAxisLabelFormatType", "1")
  		CommandApi.Do()
  	 'Change the number of digits
  		CommandApi.Option ("AxesXAxisLabelFormatNumDigits", "3")
  		CommandApi.Do()
  	 'Change the label prefix
  	 	CommandApi.Option ("AxesXAxisLabelFormatPrefix", "X-")
  	 	CommandApi.Do()
  	 'Change the label postfix
  	 	CommandApi.Option ("AxesXAxisLabelFormatPostfix", " cm")
  	 	CommandApi.Do()

 'Show Y Axis
  CommandApi.Option ("AxesYAxisShow", "True")
  CommandApi.Do()
  'Change the Y Axis properties
	 'Change the Y Axis color
  		CommandApi.Option ("AxesYAxisColor", "light green")
  		CommandApi.Do()
	 'Change the Y Axis start value
  		CommandApi.Option ("AxesYAxisBeg", "20")
  		CommandApi.Do()
	 'Change the Y Axis ending value
  		CommandApi.Option ("AxesYAxisEnd", "110")
  		CommandApi.Do()
	 'Change the value that the Y Axis crosses the Z axis
  		CommandApi.Option ("AxesYAxisCross1", "50")
  		CommandApi.Do()
	 'Change the value that the Y Axis crosses the X axis
  		CommandApi.Option ("AxesYAxisCross2", "0")
  		CommandApi.Do()
	 'Change the angle where the axis labels are located
		  CommandApi.Option ("AxesYAxisPlane", "45")
  		CommandApi.Do()
	 'Assign a title to the Y Axis
  		CommandApi.Option ("AxesYAxisTitle", "Y Axis Title")
  		CommandApi.Do()
	 'Show the Y Axis labels
  		CommandApi.Option ("AxesYAxisShowLabels", "True")
  		CommandApi.Do()
	 'Flip the Y Axis labels in the horizontal direction
  		CommandApi.Option ("AxesYAxisFlipLabelsX", "True")
  		CommandApi.Do()
	 'Flip the Y Axis labels in the vertical direction
  		CommandApi.Option ("AxesYAxisFlipLabelsY", "True")
  		CommandApi.Do()
	 'Change the starting Y Axis label
  		CommandApi.Option ("AxesYAxisLabelBeg", "30")
  		CommandApi.Do()
	 'Change the ending Y Axis label
  		CommandApi.Option ("AxesYAxisLabelEnd", "85")
  		CommandApi.Do()
	 'Change the Y Axis label increment
  		CommandApi.Option ("AxesYAxisLabelInc", "5")
  		CommandApi.Do()
	 'Change the Y Axis label angle
  		CommandApi.Option ("AxesYAxisLabelAngle", "75")
  		CommandApi.Do()
	 'Change the number of ticks between major ticks
  		CommandApi.Option ("AxesYAxisTicksPerLabel", "2")
  		CommandApi.Do()
	 'Change the label format
  		CommandApi.Option ("AxesYAxisLabelFormatType", "1")
  		CommandApi.Do()
  	 'Change the number of digits
  		CommandApi.Option ("AxesYAxisLabelFormatNumDigits", "3")
  		CommandApi.Do()
  	 'Change the label prefix
  	 	CommandApi.Option ("AxesYAxisLabelFormatPrefix", "Y-")
  	 	CommandApi.Do()
  	 'Change the label postfix
  	 	CommandApi.Option ("AxesYAxisLabelFormatPostfix", " cm")
  	 	CommandApi.Do()

 'Show Z Axis
  CommandApi.Option ("AxesZAxisShow", "True")
  CommandApi.Do()
  'Change the Z Axis properties
	 'Change the Z Axis color
  		CommandApi.Option ("AxesZAxisColor", "light green")
  		CommandApi.Do()
	 'Change the Z Axis start value
  		CommandApi.Option ("AxesZAxisBeg", "50")
  		CommandApi.Do()
	 'Change the Z Axis ending value
  		CommandApi.Option ("AxesZAxisEnd", "100")
  		CommandApi.Do()
	 'Change the value that the Z Axis crosses the X axis
  		CommandApi.Option ("AxesZAxisCross1", "0")
  		CommandApi.Do()
	 'Change the value that the Z Axis crosses the Y axis
  		CommandApi.Option ("AxesZAxisCross2", "0")
  		CommandApi.Do()
	 'Change the angle where the axis labels are located
		  CommandApi.Option ("AxesZAxisPlane", "45")
  		CommandApi.Do()
	 'Assign a title to the Z Axis
  		CommandApi.Option ("AxesZAxisTitle", "Z Axis Title")
  		CommandApi.Do()
	 'Show the Z Axis labels
  		CommandApi.Option ("AxesZAxisShowLabels", "True")
  		CommandApi.Do()
	 'Flip the Z Axis labels in the horizontal direction
  		CommandApi.Option ("AxesZAxisFlipLabelsX", "True")
  		CommandApi.Do()
	 'Flip the Z Axis labels in the vertical direction
  		CommandApi.Option ("AxesZAxisFlipLabelsY", "True")
  		CommandApi.Do()
	 'Change the starting Z Axis label
  		CommandApi.Option ("AxesZAxisLabelBeg", "30")
  		CommandApi.Do()
	 'Change the ending Z Axis label
  		CommandApi.Option ("AxesZAxisLabelEnd", "85")
  		CommandApi.Do()
	 'Change the Z Axis label increment
  		CommandApi.Option ("AxesZAxisLabelInc", "5")
  		CommandApi.Do()
	 'Change the Z Axis label angle
  		CommandApi.Option ("AxesZAxisLabelAngle", "75")
  		CommandApi.Do()
	 'Change the number of ticks between major ticks
  		CommandApi.Option ("AxesZAxisTicksPerLabel", "2")
  		CommandApi.Do()
	 'Change the label format
  		CommandApi.Option ("AxesZAxisLabelFormatType", "1")
  		CommandApi.Do()
  	 'Change the number of digits
  		CommandApi.Option ("AxesZAxisLabelFormatNumDigits", "3")
  		CommandApi.Do()
  	 'Change the label prefix
  	 	CommandApi.Option ("AxesZAxisLabelFormatPrefix", "Z-")
  	 	CommandApi.Do()
  	 'Change the label postfix
  	 	CommandApi.Option ("AxesZAxisLabelFormatPostfix", " cm")
  	 	CommandApi.Do()

 'Recalculate the automatic scaling
  CommandApi.Option ("AxesAutoScale", "True")
  CommandApi.Do()

 'Show the X, Y, and Z axis grid lines
  CommandApi.Option ("AxesShowGrid", "True")
  CommandApi.Do()

 'Set the X, Y, and Z axis grid line color
  CommandApi.Option ("AxesGridColor", "Pale Yellow")
  CommandApi.Do()

 'Set the grid line width
  CommandApi.Option ("AxesGridLineWidth", "3.0")
  CommandApi.Do()

 'Set the thickness for the X, Y, and Z axes
 'Ranges from 0 to 15
  CommandApi.Option ("AxesThickness", "2.3")
  CommandApi.Do()

 'Turn on display of arrowheads at ends of axes
  CommandApi.Option ("AxesShowArrows", "True")
  CommandApi.Do()

 'Set the font face for the axes labels and titles
 'Name of font
  CommandApi.Option ("AxesFont", "Times New Roman")
  CommandApi.Do()

 'Set the label height
 'Ranges from 1.192092896e-007 to 10
  CommandApi.Option ("AxesLabelHeight", "0.7")
  CommandApi.Do()

 'Set the title height
 'Ranges from 1.192092896e-007 to 10
  CommandApi.Option ("AxesTitleHeight", "0.7")
  CommandApi.Do()


End Sub

 

Updated October 18, 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.