Follow

How can I slice my lattice in Voxler via automation?

This article contains a sample script for creating a test lattice, adding a Slice module, and changing the properties of the Slice.

To run this script:

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

*********

'********************************************************************************************
' SliceModule.bas
' This script creates a test lattice.
' It adds a Slice module and changes the properties of the Slice.
'********************************************************************************************

' 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 a test lattice
  CommandApi.Construct ("CreateModule")
  CommandApi.Option("Type", "TestLattice")
  CommandApi.Do()

 'Add a Slice module to the test lattice
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "Slice")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "TestLattice")
  CommandApi.Do()

 'Add a Contours module to the slice
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "Contours")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Slice")
  CommandApi.Do()

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

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

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

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

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

 'Display the cutting plane dragger
  CommandApi.Option ("LatticeSlicePlaneShowDragger", "True")
  CommandApi.Do()

 'Turn on/off the slice trilinear interpolation
  CommandApi.Option ("LatticeSliceInterpolate", "True")
  CommandApi.Do()

 'Change the number of nodes in the X direction of the output slice
  CommandApi.Option ("LatticeSliceXResolution", "50")
  CommandApi.Do()

 'Change the number of nodes in the Y direction of the output slice
  CommandApi.Option ("LatticeSliceYResolution", "34")
  CommandApi.Do()

 'Show/hide the border around the edge of the slice plane
  CommandApi.Option ("LatticeSliceBorderShow", "True")
  CommandApi.Do()

 'Change the border line width around the slice plane
 'Value is between 0 and 4
  CommandApi.Option ("LatticeSliceBorderWidth", "2.3")
  CommandApi.Do()

 'Change the border line color around the slice plane
 'Value is a color name
  CommandApi.Option ("LatticeSliceBorderColor", "Sky Blue")
  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.