Follow

How can I resample a lattice in Voxler via automation?

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

To run this script:

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

*********

'********************************************************************************************
' ResampleModule.bas
' This script creates a function lattice.
' It adds a resample module and changes the properties of the resample module.
'********************************************************************************************

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

 'Add a Resample module to the function lattice
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "Resample")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "FunctionLattice")
  CommandApi.Do()

 'Add Info module to Resample to look at output
 CommandApi.Option ("Type", "Info")
 CommandApi.Option ("SourceModule", "Resample")
 CommandApi.Do()

 'Turn on/off the "Calculate from Inputs" option
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Resample")
  CommandApi.Option ("LatticeResampleAuto", "False")
  CommandApi.Do()

 'Set the X Axis minimum value
  CommandApi.Option ("LatticeResampleXMin", "0.2")
  CommandApi.Do()

 'Set the X Axis maximum value
  CommandApi.Option ("LatticeResampleXMax", "0.6")
  CommandApi.Do()

 'Set the Y Axis minimum value
  CommandApi.Option ("LatticeResampleYMin", "0.2")
  CommandApi.Do()

 'Set the Y Axis maximum value
  CommandApi.Option ("LatticeResampleYMax", "0.6")
  CommandApi.Do()

 'Set the Z Axis minimum value
  CommandApi.Option ("LatticeResampleZMin", "0.2")
  CommandApi.Do()

 'Set the Z Axis maximum value
  CommandApi.Option ("LatticeResampleZMax", "0.6")
  CommandApi.Do()

 'Set the number of nodes in the X direction
  CommandApi.Option ("LatticeResampleXNum", "30")
  CommandApi.Do()

 'Set the number of nodes in the Y direction
  CommandApi.Option ("LatticeResampleYNum", "30")
  CommandApi.Do()

 'Set the number of nodes in the Z direction
  CommandApi.Option ("LatticeResampleZNum", "30")
  CommandApi.Do()

 'Set the resample method
 'Value is 0 or 1 for Nearest Neighbor or Trilinear
  CommandApi.Option ("LatticeResampleMethod", "1")
  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.