Follow

How can I create an ObliqueImage in Voxler via automation?

This article contains a sample script for loading a file, adding an obliqueimage module, and then changing all the properties of the obliqueimage.

To run this script:

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

*********

'********************************************************************************************
' ObliqueImageModule.bas
' This script loads a file and adds a obliqueimage module.
' It then changes all the properties of the obliqueimage.
'********************************************************************************************

' 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 an image file
  CommandApi.Construct ("Import")
  CommandApi.Option ("Path", VoxlerApp.Path+"\Samples\Jaw.vdat")
  CommandApi.Do()

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

 'Change the obliqueslice component
  CommandApi.Construct("ModifyModule")
  CommandApi.Option("Module","ObliqueImage")
  CommandApi.Option("ObliqueSliceComponent", "1")
  CommandApi.Do()

 'Change the obliqueslice resolution
 '0, 1, 2, 3 for coarse, medium, fine, or very fine
  CommandApi.Option("ObliqueSliceResolution", "3")
  CommandApi.Do()

 'Turn on/off the obliqueslice interpolation
  CommandApi.Option("ObliqueSliceInterp", "True")
  CommandApi.Do()

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

 'Change the obliqueslice opacity
  CommandApi.Option("ObliqueSliceOpacity", "0.4")
  CommandApi.Do()

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

 'Change the obliqueslice map width
 'Only available when the ObliqueSliceMapping method is 0 (Linear)
  CommandApi.Option("ObliqueSliceMapWidth", "12")
  CommandApi.Do()

 'Change the obliqueslice map center
 'Only available when the ObliqueSliceMapping method is 0 (Linear)
  CommandApi.Option("ObliqueSliceMapCenter", "12")
  CommandApi.Do()

 'Change the obliqueslice color map
 'Only available when the ObliqueSliceMapping method is 1 (ColorMap)
  CommandApi.Option("ObliqueSliceColormap", "Rainbow")
  CommandApi.Do()

 'Display the ObliqueSlice legend
  CommandApi.Option ("ObliqueSliceLegendEnable", "True")
  CommandApi.Do()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 'Turn on or off the display of the legend background
  CommandApi.Option ("ObliqueSliceLegendShowBackground", "True")
  CommandApi.Do()

 'Change the cutting plane orientation
 'Value is 0, 1, 2, or 3 for XY Plane (Axial), XZ Plane (Coronal), YZ Plane (Sagittal), or Custom
  CommandApi.Option ("ObliqueSlicePlaneOrientation", "2")
  CommandApi.Do()

 'Change the X Normal Direction For the cutting plane
 'Only available if ObliqueSlicePlaneOrientation is set to 3
  CommandApi.Option ("ObliqueSlicePlaneXNormal", "30")
  CommandApi.Do()

 'Change the Y Normal Direction For the cutting plane
 'Only available if ObliqueSlicePlaneOrientation is set to 3
  CommandApi.Option ("ObliqueSlicePlaneYNormal", "30")
  CommandApi.Do()

 'Change the Z Normal Direction For the cutting plane
 'Only available if ObliqueSlicePlaneOrientation is set to 3
  CommandApi.Option ("ObliqueSlicePlaneZNormal", "60")
  CommandApi.Do()

 'Change the offset of the cutting plane from the center of the lattice
  CommandApi.Option ("ObliqueSlicePlaneOffset", "-7.5")
  CommandApi.Do()

 'Display the cutting plane dragger
  CommandApi.Option ("ObliqueSlicePlaneShowDragger", "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.