Follow

How can I create a test lattice in Voxler using a script?

This article contains a sample script for creating a TestLattice module and changing its properties.

To run this script:

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

*********

'********************************************************************************************
' TestLatticeModule.bas
' This script creates a TestLattice module and changes its properties.
'********************************************************************************************

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

 'Attach an isosurface to the test lattice
  CommandApi.Construct ("CreateModule")
  CommandApi.Option("Type", "Isosurface")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "TestLattice")
  CommandApi.Do()

 'Change the function being displayed
 'Value is 0, 1, 2, 3, 4, or 5 for Knotted Torus, Spherical Density, Vector Vortex
 'Wiffle Cube, Jack, or Knotted Rope
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "TestLattice")
  CommandApi.Option ("TestLatticeMethod", "4")
  CommandApi.Do()

 'Change the output lattice type
 '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), or Double (64 bits).
  CommandApi.Option ("TestLatticeOutType", "6")
  CommandApi.Do()

 'Change the lattice X minimum value
  CommandApi.Option ("TestLatticeXMin", "-1")
  CommandApi.Do()

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


 'Change the lattice Y maximum value
  CommandApi.Option ("TestLatticeYMax", "10")
  CommandApi.Do()

 'Change the lattice Y minimum value
  CommandApi.Option ("TestLatticeYMin", "2")
  CommandApi.Do()

  'Change the lattice Z maximum value
  CommandApi.Option ("TestLatticeZMax", "10")
  CommandApi.Do()

 'Change the lattice Z minimum value
  CommandApi.Option ("TestLatticeZMin", "1")
  CommandApi.Do()

 '
 'Change the number of nodes in the X direction
  CommandApi.Option ("TestLatticeXNum", "40")
  CommandApi.Do()

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

 'Change the number of nodes in the Z direction
  CommandApi.Option ("TestLatticeZNum", "50")
  CommandApi.Do()
VoxlerApp.Quit
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.