How can I delete a module in a Voxler script?

This article contains a sample script for loading an existing VOXB file, deleting a module, undoing the deletion, clearing the undo history, and deleting all the modules.

To run this script:

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


' DeleteModule.bas
' This script loads an existing VOXB file.  It deletes a module, undoes the deletion,
' clears the undo history, and deletes all the modules.

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

 'Open an existing file
  CommandApi.Construct ("Open")
  CommandApi.Option ("Path", VoxlerApp.Path+"\Samples\Inversion (Isosurfaces).voxb")

  'Wait 4 seconds to see the original model

 'Delete the Axes module from the network
  CommandApi.Construct ("DeleteModule")
  CommandApi.Option ("Module","Axes")

 'Wait 4 seconds to see the result

 'Undo delete module

 'Wait 4 seconds to see the result

 'Clear undo history
  CommandApi.Construct ("ClearHistory")

 'Delete all remaining modules in the network window
  CommandApi.Construct ("DeleteAllModules")

End Sub


Updated September 6, 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.