Follow

How can I create a 3D surface (HeightField) in Voxler via automation?

This article contains a sample script for loading a test lattice, adding a HeightField module, and changing all the properties of the HeightField.

To run this script:

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

*********

'********************************************************************************************
' HeightfieldModule.bas
' This script loads a test lattice and adds a heightfield module.
' It then changes all the properties of the heightfield.
'********************************************************************************************

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

 'Create the test lattice
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("Type", "TestLattice")
  CommandApi.Do()

 'Add a heightfield module
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "TestLattice")
  CommandApi.Option ("Type", "HeightField")
  CommandApi.Do()

 'Change the component being shown by the heightfield
 'Only available if more than one component exists in the lattice
  CommandApi.Construct("ModifyModule")
  CommandApi.Option("Module","HeightField")
  CommandApi.Option("HeightFieldComponent", "1")
  CommandApi.Do()

 'Change the height field drawing style
 'this is 0, 1, or 2 for shaded, lines, or points
  CommandApi.Option("HeightFieldDrawStyle", "1")
  CommandApi.Do()

 'Change the height field orientation
 'this is 0, 1, or 2 for XY Plane (Axial), XZ Plane (Coronal), or YZ Plane (Sagittal)
 'this is only available when more than one grid node exists in each direction
  CommandApi.Option("HeightFieldOrientation", "1")
  CommandApi.Do()

 'Change the height field slice number
 'this is a number from 1 to the maximum grid row in the orientation direction
 'this is only available when more than one grid node exists in each direction
  CommandApi.Option("HeightFieldSlice", "18")
  CommandApi.Do()

 'Change the height field opacity
 'this is a number from 0 to 1
  CommandApi.Option("HeightFieldOpacity", "0.4")
  CommandApi.Do()

 'Change the height field color map
  CommandApi.Option("HeightFieldColormap", "Rainbow")
  CommandApi.Do()

 'Change the height field scale
  CommandApi.Option("HeightFieldScale", "0.6")
  CommandApi.Do()

 'Display the height field legend
  CommandApi.Option ("HeightFieldLegendEnable", "True")
  CommandApi.Do()

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

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

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

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

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

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

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

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

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

 'Set the custom labels for the legend
  CommandApi.Option ("HeightFieldLegendCustomLabels", "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 ("HeightFieldLegendLabelHeight", "8")
  CommandApi.Do()

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

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

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

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

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

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

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

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

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