Follow

How can I create an OrthoImage in Voxler via automation?

This article contains a sample script for loading a file, adding an OrthoImage module, and changes all the properties of the OrthoImage.

To run this script:

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

*********

'********************************************************************************************
' OrthoImageModule.bas
' This script loads a file and adds a OrthoImage module.
' It then changes all the properties of the OrthoImage.
'
'                                    -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()

 'Import a file
  CommandApi.Construct ("Import")
  CommandApi.Option ("Path", VoxlerApp.Path+"\Samples\Jaw.vdat")
  CommandApi.Option ("Filter", "vdat")
  CommandApi.Do()

 'Create a OrthoImage and attach it to the data
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "OrthoImage")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Jaw.vdat")
  CommandApi.Do()

 'Change the OrthoImage component
  CommandApi.Construct("ModifyModule")
  CommandApi.Option("Module","OrthoImage")
  CommandApi.Option("OrthoSliceComponent", "1")
  CommandApi.Do()

 'Change the OrthoImage orientation
 '0, 1, 2 for XY Plane (Axial), XZ Plane (Coronal), or YZ Plane (Sagittal)
  CommandApi.Option("OrthoSliceOrientation", "2")
  CommandApi.Do()

 'Change the slice number being shown
  CommandApi.Option("OrthoSliceSlice", "32")
  CommandApi.Do()

 'Turn on/off the orthoslice lighting
  CommandApi.Option("OrthoSliceLighting", "True")
  CommandApi.Do()

 'Adjust the orthoslice quality
 'Value between 0 and 1
  CommandApi.Option("OrthoSliceQuality", "0.7")
  CommandApi.Do()

 'Change the orthoslice opacity
  CommandApi.Option("OrthoSliceOpacity", "0.4")
  CommandApi.Do()

 'Change the OrthoSlice mapping value
 'Changes the Mapping Method
 'Values are 0 or 1, 0=Linear, 1=ColorMap
  CommandApi.Option("OrthoSliceMapping", "0")
  CommandApi.Do()

 'Change the orthoslice map width
 'Only available when the OrthoSliceMapping method is 0 (Linear)
  CommandApi.Option("OrthoSliceMapwidth", "12")
  CommandApi.Do()

 'Change the orthoslice map center
 'Only available when the OrthoSliceMapping method is 0 (Linear)
  CommandApi.Option("OrthoSliceMapcenter", "12")
  CommandApi.Do()

  Wait(2)

 'Change the OrthoSlice mapping value
 'Changes the Mapping Method
 'Values are 0 or 1, 0=Linear, 1=ColorMap
  CommandApi.Option("OrthoSliceMapping", "1")
  CommandApi.Do()

 'Change the orthoslice color map
 'Only available when the OrthoSliceMapping method is 1 (ColorMap)
  CommandApi.Option("OrthoSliceColormap", "Rainbow")
  CommandApi.Do()

 'Display the OrthoSlice legend
  CommandApi.Option ("OrthoSliceLegendEnable", "True")
  CommandApi.Do()

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

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

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

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

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

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

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

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

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

 'Set the custom labels for the legend
  CommandApi.Option ("OrthoSliceLegendCustomLabels", "1.7:low, 49:medium, 100:intermediate, 180:elevated, 220:high")
  CommandApi.Do()

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

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

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

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

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

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

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

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

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

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