How can I export all possible Heightfield slices from a 3D lattice

This article contains a sample script to open an existing VOXB project that contains a 3D lattice with a Heightfield module attached. It loops through all three orientations and exports each slice to JPG (150 slices total)

To run this script:

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



' Export all slices.bas
' This script opens an existing VOXB project that contains a 3D lattics with a Heightfield module.
' It loops through all three orientations and exports each slice to JPG (150 slices total) ''******************************************************************************************** ' 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 'Open an existing file CommandApi.Construct ("Open") CommandApi.Option ("Path", "C:\Users\Justine\Desktop\TestIn\Test.voxb") CommandApi.DoOnce() 'Define the beginning index values. i is the Heightfile orientation, j is the Heightfield slice number
i=0 j=1
'Initialize the first loop While i <3 j=1 CommandApi.Construct("ModifyModule") CommandApi.Option("Module","HeightField") CommandApi.Option("HeightFieldOrientation", i) CommandApi.Do()
'Initialize the second loop While j <51
'Export the slice to JPG CommandApi.Construct("Export") CommandApi.Option("GuiEnabled", "False") CommandApi.Option("ClearOptions", "False") CommandApi.Option("Filter", "jpg") CommandApi.Option("Options", "Height=2048; Width=1024") CommandApi.Option("Path", "C:\Users\Justine\Desktop\TestOut\"+"orientation"+ i+"-"+"slice"+j+ ".jpg") CommandApi.Option("PersistOptions", "True") CommandApi.Option("ModuleId", "0") CommandApi.Do()
'Increment the slice j+=1 CommandApi.Construct("ModifyModule") CommandApi.Option("Module","HeightField") CommandApi.Option("HeightFieldSlice", j) CommandApi.Do() Wend
'Increment the orientation i+=1 Wend VoxlerApp.Quit End Sub


Updated July 20, 2018

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.