Follow

How can I load a lattice via Voxler automation?

This article contains a sample script for loading a lattice file and then changing the properties of the lattice.

To run this script:

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

*********

'********************************************************************************************
' LoadLattice.bas
' This script loads a lattice file.
' It then changes the properties of the lattice.
'********************************************************************************************

' 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()

 'Loads an HDF file
  CommandApi.Construct ("Import")
  CommandApi.Option ("GuiEnabled", "False")
  CommandApi.Option ("Filter", "hdf")
  CommandApi.Option ("Path", VoxlerApp.Path+"\Samples\Temperature.hdf")
  CommandApi.Do()

 'Attach a contour to the lattice
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "Contours")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Temperature.hdf")
  CommandApi.Do()

Wait (4)

 'Delete the contour module
  CommandApi.Construct ("DeleteModule")
  CommandApi.Option ("Module", "Contours")
  CommandApi.Do()

 'Change the file path for the lattice file
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Temperature.hdf")
  CommandApi.Option ("LatticeSrcFilename", VoxlerApp.Path + "\Samples\Engine.vdat")
  CommandApi.Do()

 'Attach an isosurface to the new data
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "Isosurface")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Engine.vdat")
  CommandApi.Do()

 'Attach axes to the new data
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "Axes")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Engine.vdat")
  CommandApi.Do()

Wait (4)

 'Change the X minimum value
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Engine.vdat")
  CommandApi.Option ("LatticeSrcXmin", "-10")
  CommandApi.Do()

 'Change the X maximum value
  CommandApi.Option ("LatticeSrcXmax", "100")
  CommandApi.Do()

 'Change the Y minimum value
  CommandApi.Option ("LatticeSrcYmin", "0")
  CommandApi.Do()

 'Change the Y maximum value
  CommandApi.Option ("LatticeSrcYmax", "50")
  CommandApi.Do()

 'Change the Z minimum value
  CommandApi.Option ("LatticeSrcZmin", "10")
  CommandApi.Do()

 'Change the Z maximum value
  CommandApi.Option ("LatticeSrcZmax", "60")
  CommandApi.Do()

 'Update the lattice extents on the map
  CommandApi.Option ("LatticeSrcUpdateLimits", "True")
  CommandApi.Do()

Wait (2)

 'Reset the limits
  CommandApi.Option ("LatticeSrcResetLimits", "True")
  CommandApi.Do()

 'Show the data
  CommandApi.Option ("LatticeSrcShowData", "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.