Follow

How can I create a Function Lattice in Voxler via automation?

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

To run this script:

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

*********

'********************************************************************************************
' FunctionLatticeModule.bas
' This script creates a function lattice and changes the properties of the function lattice.
''********************************************************************************************

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

 'Change the X minimum value for the function lattice
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "FunctionLattice")
  CommandApi.Option ("FunctionLatticeXMin", "1")
  CommandApi.Do()

 'Change the X maximum value for the function lattice
  CommandApi.Option ("FunctionLatticeXMax", "10")
  CommandApi.Do()

 'Change the Y minimum value for the function lattice
  CommandApi.Option ("FunctionLatticeYMin", "-5")
  CommandApi.Do()

 'Change the Y maximum value for the function lattice
  CommandApi.Option ("FunctionLatticeYMax", "5")
  CommandApi.Do()

 'Change the Z minimum value for the function lattice
  CommandApi.Option ("FunctionLatticeZMin", "-.5")
  CommandApi.Do()

 'Change the Z maximum value for the function lattice
  CommandApi.Option ("FunctionLatticeZMax", "0.5")
  CommandApi.Do()

 'Change the number of nodes in the X direction for the function lattice
  CommandApi.Option ("FunctionLatticeXNum", "30")
  CommandApi.Do()

 'Change the number of nodes in the Y direction for the function lattice
  CommandApi.Option ("FunctionLatticeYNum", "40")
  CommandApi.Do()

 'Change the number of nodes in the Z direction for the function lattice
  CommandApi.Option ("FunctionLatticeZNum", "10")
  CommandApi.Do()

 'Change the type of values stored in the function lattice
 'Value is 0, 1, 2, 3, 4, 5, 6, 7, 8 for
 'Signed 8 bits, Unsigned 8 bits, Signed 16 bits, Unsigned 16 bits, Signed 32 bits,
 'Unsigned 32 bits, Signed 64 bits, Float (32 bits), Double (64 bits)
  CommandApi.Option ("FunctionLatticeOutType", "7")
  CommandApi.Do()

 'Change the number of components in the function lattice
  CommandApi.Option ("FunctionLatticeOutComps", "20")
  CommandApi.Do()

 'Change the component 1 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp1", "(x-.5)*(x-.5) + (y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 2 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp2", "(x-.5) + (y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 3 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp3", "(x-.5) + (y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 4 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp4", "(x-.5) + (y-.5) + (z-.5)")
  CommandApi.Do()

 'Change the component 5 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp5", "(x+.5)*(x+.5) + (y+.5)*(y+.5) + (z+.5)*(z+.5)")
  CommandApi.Do()

 'Change the component 6 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp6", "(x+.5) + (y+.5)*(y+.5) + (z+.5)*(z+.5)")
  CommandApi.Do()

 'Change the component 7 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp7", "(x+.5) + (y+.5) + (z+.5)")
  CommandApi.Do()

 'Change the component 8 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp8", "(x+.5)*(x-.5) + (y+.5)*(y-.5) + (z+.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 9 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp9", "x*(x+.5)*(x-.5) + (y+.5)*(y-.5) + (z+.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 10 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp10", "x*(x-.5)*(x-.5) + y*(y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 11 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp11", "x*(x-.5)*(x-.5) + y*(y-.5)*(y-.5) + z*(z-.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 12 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp12", "y*(x-.5)*(x-.5) + (y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 13 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp13", "(x-.5)*(x-.5) + x*(y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 14 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp14", "(x-.5)*(x-.5) + (y-.5)*(y-.5) + x*y*(z-.5)*(z-.5)")
  CommandApi.Do()

 'Change the component 15 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp15", "(x + y + z)")
  CommandApi.Do()

 'Change the component 16 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp16", "(x*x) + (y*y) + (z*z)")
  CommandApi.Do()

 'Change the component 17 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp17", "(x*2) + (2*y) + (2*z)")
  CommandApi.Do()

 'Change the component 18 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp18", "(x*2) + (2*y) + (2*z)")
  CommandApi.Do()

 'Change the component 19 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp19", "(x-2) + (2-y) + (2-z)")
  CommandApi.Do()

 'Change the component 20 function on the function lattice
  CommandApi.Option ("FunctionLatticeExprComp20", "(x+2) + (2*y) + (2+z)")
  CommandApi.Do()

  'Attach an info module to the function lattice
  CommandApi.Construct("CreateModule")
  CommandApi.Option("Type", "Info")
  CommandApi.Option("AutoConnect", "True")
  CommandApi.Option("SourceModule", "FunctionLattice")
  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.