Follow

How can I use a Voxler script to add a change type module to my lattice?

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


To run this script:

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

*********

'********************************************************************************************
' ChangeTypeModule.bas
' This script creates a function lattice.
' It adds a change type module and changes the properties of the change type 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
  Debug.Clear

 'Create a new Voxler document
  Set ok = CommandApi.Construct ("New")
  Debug.Print ok; ": Construct (New)"

  ok = CommandApi.DoOnce()
  Debug.Print ok; " DoOnce()"

 'Create a function lattice
  ok = CommandApi.Construct ("CreateModule")
  Debug.Print ok; " Construct (CreateModule)"
  ok = CommandApi.Option("Type", "FunctionLattice")
  Debug.Print ok; " Option(Type, FunctionLattice): "
  ok = CommandApi.Do()
  Debug.Print ok; ": Do()"

  'Add an info module to the function lattice
  ok = CommandApi.Option("Type", "Info")
  Debug.Print ok; ": Option(Type, Info)"
  ok = CommandApi.Option("AutoConnect", "True")
  Debug.Print ok; ": Option(AutoConnect, True)"
  ok = CommandApi.Option("SourceModule", "FunctionLattice")
  Debug.Print ok; ": Option(SourceModule, FunctionLattice)"
  ok = CommandApi.Do()
  Debug.Print ok; ": Do()"

 'Add a change type module to the function lattice
  ok = CommandApi.Option ("Type", "ChangeType")
  Debug.Print ok; ": Option(Type, ChangeType)"
  ok = CommandApi.Do()
  Debug.Print ok; ": Do()"

  'Add another Info module to the ChangeType
  ok = CommandApi.Option("Type", "Info")
  Debug.Print ok; ": Option(Type, Info)"
  ok = CommandApi.Option("SourceModule", "ChangeType")
  Debug.Print ok; ": Option(SourceModule, ChangeType)"
  ok = CommandApi.Do()
  Debug.Print ok; ": 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), Double (64 bits)
  ok = CommandApi.Construct ("ModifyModule")
  Debug.Print ok; " Construct (ModifyModule)"
  ok = CommandApi.Option ("Module", "ChangeType")
  Debug.Print ok; ": Option(Module, ChangeType)"
  ok = CommandApi.Option ("ChangeTypeOutputType", "7")
  Debug.Print ok; ": Option(ChangeTypeOutputType, 7)"
  ok = CommandApi.Do()
  Debug.Print ok; ": Do()"

 'Change the offset for the change type module output
  ok = CommandApi.Option ("ChangeTypeOffset", "20")
  Debug.Print ok; ": Option(ChangeTypeOffset, 20)"
  ok = CommandApi.Do()
  Debug.Print ok; ": Do()"

 'Change the scale for the change type module output
  ok = CommandApi.Option ("ChangeTypeScale", "0.6")
  Debug.Print ok; ": Option(ChangeTypeScale, 0.6)"
  ok = CommandApi.Do()
  Debug.Print ok; ": Do()"

Wait (2)

 'Change the stretch factor for the change type module output
  ok = CommandApi.Option ("ChangeTypeStretch", "True")
  Debug.Print ok; ": Option(ChangeTypeStretch, True)"
  ok = CommandApi.Do()
  Debug.Print ok; ": 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.