Follow

How can I combine two lattices in Voxler via automation?

This article contains a sample script for creating two function lattices, adding a merge module and changing the properties of the merge module.

To run this script:

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

*********

'********************************************************************************************
' MergeModule.bas
' This script creates two function lattices.
' It adds a merge module and changes the properties of the merge 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 second function lattice
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "FunctionLattice")
  CommandApi.Do()

 'Set the function lattice 2 equation
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "FunctionLattice 2")
  CommandApi.Option ("FunctionLatticeExprComp1", "2*x+y+0.5*z")
  CommandApi.Do()

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

 'Connect the merge module to the second function lattice
  CommandApi.Construct ("ConnectModules")
  CommandApi.Option ("SourceModule", "FunctionLattice 2")
  CommandApi.Option ("TargetModule", "Merge")
  CommandApi.Option ("TargetPort", "1")
  CommandApi.Do()

  'Attach an Info module to view the output
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "Info")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Merge")
  CommandApi.Do()

 'Turn on/off the "Calculate from Inputs" option for the Merge module
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Merge")
  CommandApi.Option ("LatticeMergeAuto", "False")
  CommandApi.Do()

 'Set the X Axis minimum value for the Merge module
  CommandApi.Option ("LatticeMergeXMin", "0.2")
  CommandApi.Do()

 'Set the X Axis maximum value for the Merge module
  CommandApi.Option ("LatticeMergeXMax", "0.6")
  CommandApi.Do()

 'Set the Y Axis minimum value for the Merge module
  CommandApi.Option ("LatticeMergeYMin", "0.2")
  CommandApi.Do()

 'Set the Y Axis maximum value for the Merge module
  CommandApi.Option ("LatticeMergeYMax", "0.6")
  CommandApi.Do()

 'Set the Z Axis minimum value for the Merge module
  CommandApi.Option ("LatticeMergeZMin", "0.2")
  CommandApi.Do()

 'Set the Z Axis maximum value for the Merge module
  CommandApi.Option ("LatticeMergeZMax", "0.6")
  CommandApi.Do()

 'Set the number of nodes in the X direction for the Merge module
  CommandApi.Option ("LatticeMergeXNum", "30")
  CommandApi.Do()

 'Set the number of nodes in the Y direction for the Merge module
  CommandApi.Option ("LatticeMergeYNum", "30")
  CommandApi.Do()

 'Set the number of nodes in the Z direction for the Merge module
  CommandApi.Option ("LatticeMergeZNum", "30")
  CommandApi.Do()

 'Set the resample method for the Merge module
 'Value is 0 or 1 for Nearest Neighbor or Trilinear
  CommandApi.Option ("LatticeMergeResample", "1")
  CommandApi.Do()

 'Set the overlap method for the Merge module
 'Value is 0, 1, 2, 3, 4, 5, 6 for Average, Count, First, Last, Maximum, Median, or Minimum
  CommandApi.Option ("LatticeMergeOverlap", "5")
  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.