Follow

How can I pull out a subset of my lattice in Voxler via automation?

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

To run this script:

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

*********

'********************************************************************************************
' SubsetModule.bas
' This script creates a function lattice.
' It adds a Subset module and changes the properties of the Subset.
'********************************************************************************************

' 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 output geometry of the function lattice
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "FunctionLattice")
  CommandApi.Option ("FunctionLatticeXNum", "20")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeYNum", "20")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeZNum", "20")
  CommandApi.Do()

 'Change the equations for the function lattice
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "FunctionLattice")
  CommandApi.Option ("FunctionLatticeOutComps", "20")
  CommandApi.Do()

  CommandApi.Option ("FunctionLatticeExprComp1", "(x-.5)*(x-.5) + (y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp2", "(x-.5) + (y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp3", "(x-.5) + (y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp4", "(x-.5) + (y-.5) + (z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp5", "(x+.5)*(x+.5) + (y+.5)*(y+.5) + (z+.5)*(z+.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp6", "(x+.5) + (y+.5)*(y+.5) + (z+.5)*(z+.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp7", "(x+.5) + (y+.5) + (z+.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp8", "(x+.5)*(x-.5) + (y+.5)*(y-.5) + (z+.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp9", "x*(x+.5)*(x-.5) + (y+.5)*(y-.5) + (z+.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp10", "x*(x-.5)*(x-.5) + y*(y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp11", "x*(x-.5)*(x-.5) + y*(y-.5)*(y-.5) + z*(z-.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp12", "y*(x-.5)*(x-.5) + (y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp13", "(x-.5)*(x-.5) + x*(y-.5)*(y-.5) + (z-.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp14", "(x-.5)*(x-.5) + (y-.5)*(y-.5) + x*y*(z-.5)*(z-.5)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp15", "(x + y + z)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp16", "(x*x) + (y*y) + (z*z)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp17", "(x*2) + (2*y) + (2*z)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp18", "(x*2) + (2*y) + (2*z)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp19", "(x-2) + (2-y) + (2-z)")
  CommandApi.Do()
  CommandApi.Option ("FunctionLatticeExprComp20", "(x+2) + (2*y) + (2+z)")
  CommandApi.Do()

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

 'Turn on/off the "Calculate from inputs" option for the Subset
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Subset")
  CommandApi.Option ("SubsetAuto", "False")
  CommandApi.Do()

 'Change the first i index to extract for the Subset module
 'This is an integer between 1 and the number of nodes in the X direction
  CommandApi.Option("SubsetXFirst", "7")
  CommandApi.Do()

 'Change the last i index to extract for the Subset module
 'This is an integer between 1 and the number of nodes in the X direction
  CommandApi.Option("SubsetXLast", "10")
  CommandApi.Do()

 'Change the  i index step value to extract for the Subset module
 'This is an integer between 1 and the number of nodes in the X direction
  CommandApi.Option ("SubsetXStep", "2")
  CommandApi.Do()

 'Change the first j index to extract for the Subset module
 'This is an integer between 1 and the number of nodes in the Y direction
  CommandApi.Option ("SubsetYFirst", "4")
  CommandApi.Do()

 'Change the last j index to extract for the Subset module
 'This is an integer between 1 and the number of nodes in the Y direction
  CommandApi.Option ("SubsetYLast", "15")
  CommandApi.Do()

 'Change the  j index step value to extract for the Subset module
 'This is an integer between 1 and the number of nodes in the Y direction
  CommandApi.Option ("SubsetYStep", "3")
  CommandApi.Do()

 'Change the first k index to extract for the Subset module
 'This is an integer between 1 and the number of nodes in the Z direction
  CommandApi.Option ("SubsetZFirst", "4")
  CommandApi.Do()

 'Change the last k index to extract for the Subset module
 'This is an integer between 1 and the number of nodes in the Z direction
  CommandApi.Option ("SubsetZLast", "20")
  CommandApi.Do()

 'Change the  k index step value to extract for the Subset module
 'This is an integer between 1 and the number of nodes in the Z direction
  CommandApi.Option ("SubsetZStep", "2")
  CommandApi.Do()

 'Turn on/off the Subset for component 1
  CommandApi.Option ("SubsetComp1", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 2
  CommandApi.Option ("SubsetComp2", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 3
  CommandApi.Option ("SubsetComp3", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 4
  CommandApi.Option ("SubsetComp4", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 5
  CommandApi.Option ("SubsetComp5", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 6
  CommandApi.Option ("SubsetComp6", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 7
  CommandApi.Option ("SubsetComp7", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 8
  CommandApi.Option ("SubsetComp8", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 9
  CommandApi.Option ("SubsetComp9", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 10
  CommandApi.Option ("SubsetComp10", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 11
  CommandApi.Option ("SubsetComp11", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 12
  CommandApi.Option ("SubsetComp12", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 13
  CommandApi.Option ("SubsetComp13", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 14
  CommandApi.Option ("SubsetComp14", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 15
  CommandApi.Option ("SubsetComp15", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 16
  CommandApi.Option ("SubsetComp16", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 17
  CommandApi.Option ("SubsetComp17", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 18
  CommandApi.Option ("SubsetComp18", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 19
  CommandApi.Option ("SubsetComp19", "True")
  CommandApi.Do()

 'Turn on/off the Subset for component 20
  CommandApi.Option ("SubsetComp20", "True")
  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.