Follow

How can I filter a lattice in Voxler via automation?

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

To run this script:

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

*********

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

' 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.Option ("AutoConnect", "False")
  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 filter to the test lattice
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "Filter")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "FunctionLattice")
  CommandApi.Do()

 'Set the type of filter to apply to the lattice
 'Value is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
 'for 0=Average (Rectangular), 1=Average (Spherical), 2=Bounding, 3=Brightness & Contrast, 4=Central Moment,
 '5=Coeffiecient of Variation, 6=Distance, 7=Distance (inverse), 8=Distance 'Inf Norm', 9=Gamma Correction, 10=Gauss,
 '11=Histogram Equalization, 12=Interquartile Range, 13=Laplacian Edge Detect, 14=Maximum (dilation), 15=Mean Removal,
 '16=Median, 17=Median Difference, 18=Minimum (erosion), 19=Prewitt, 20=Quartile (lower), 21=Quartile (upper), 22=Range,
 '23=Rank, 24=Sobel Max, 25=Sobel Norm, 26=Standard Deviation, 27=Threshold Averaging, 28=Threshold Crossing,
 '29=Unsharp Mask, 30=Zero Crossing
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Filter")
  CommandApi.Option ("LatticeFilterFilter", "29")
  CommandApi.Do()

 'Set the orientation of filter to apply to the lattice
 'Value is 0, 1, 2, 3
 'for XY Planes, XZ Planes, YZ Planes, 3D
  CommandApi.Option ("LatticeFilterOrientation", "2")
  CommandApi.Do()

 'Set the edge handling for the filter to apply to the lattice
 'Value is 0, 1, 2, 3, 4, 5
 'for Blank, Ignore, Replicate, Mirror, Cyclic Wrap, Fill
  CommandApi.Option ("LatticeFilterEdge", "5")
  CommandApi.Do()

 'Set the edge fill value for the filter to apply to the lattice
 'Only available when LatticeFilterEdge is set to 5
  CommandApi.Option ("LatticeFilterEdgeValue", "0.5")
  CommandApi.Do()

 'Set the blank handling for the filter to apply to the lattice
 'Value is 0, 1, 2, 3
 'for Expanded, Leave Alone, Ignore, Fill
  CommandApi.Option ("LatticeFilterBlank", "3")
  CommandApi.Do()

 'Set the blank fill value for the filter to apply to the lattice
 'Only available when LatticeFilterBlank is set to 3
  CommandApi.Option ("LatticeFilterBlankValue", "7")
  CommandApi.Do()

 'Set the kernal size of the filter to apply to the lattice
 'Only available when LatticeFilterType is 0, 1, 4, 5, 6, 7, 8, 10, 12, 13,  14, 15, 16, 17, 18, 20, 21, 22, 23, 26, 27, 28, 29, 30
  CommandApi.Option ("LatticeFilterKernelSize", "5")
  CommandApi.Do()

 'Set the first filter parameters
 'This is only available for LatticeFilterType = 2, 3, 4, 9, 10, 27, 28, 29
 'For LatticeFilterType = 2, this is Lower Bound
 'For LatticeFilterType = 3, this is Brightness
 'For LatticeFilterType = 4, this is Power
 'For LatticeFilterType = 9, this is Gamma
 'For LatticeFilterType = 10, this is Alpha
 'For LatticeFilterType = 27, this is Threshold
 'For LatticeFilterType = 28, this is Threshold
 'For LatticeFilterType = 29, this is Alpha
  CommandApi.Option ("LatticeFilterParam0", "1.5")
  CommandApi.Do()

 'Set the second filter parameters
 'This is only available for LatticeFilterType = 2, 3, 29
 'For LatticeFilterType = 2, this is Upper Bound
 'For LatticeFilterType = 3, this is Contrast
 'For LatticeFilterType = 29, this is c
  CommandApi.Option ("LatticeFilterParam1", "0.513")
  CommandApi.Do()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 'Turn on/off the filter for component 20
  CommandApi.Option ("LatticeFilterComp20", "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.