Follow

How can I display my lattice with a gradient in Voxler via automation?

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

To run this script:

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

*********

'********************************************************************************************
' LatticeGradientModule.bas
' This script creates a function lattice.
' It adds a gradient and changes the properties of the gradient.
'********************************************************************************************

' 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 second component to the function lattice
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "FunctionLattice")
  CommandApi.Option ("FunctionLatticeOutComps", "2")
  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()

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

 'Set the component to apply to the lattice gradient
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Gradient")
  CommandApi.Option ("LatticeGradientComponent", "2")
  CommandApi.Do()

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