Follow

How can I add a bounding box and edit the properties in Voxler via automation?

This article contains a sample script for loading an existing VOXB file, adding a bounding box, then changing all the properties of the bounding box.

To run this script:

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

*********

'********************************************************************************************
' BoundingBoxModule.bas
' This script loads an existing VOXB file and adds a bounding box.
' It then changes all the properties of the bounding box.
'
'********************************************************************************************

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

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

 'Add a bounding box
  CommandApi.Construct ("CreateModule")
  CommandApi.Option ("Type", "BoundingBox")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Gridder")
  CommandApi.Do()

 'Change the bounding box color to blue
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "BoundingBox")
  CommandApi.Option ("BoundingBoxColor", "Blue")
  CommandApi.Do()

 'Change the bounding box line width to 2
  CommandApi.Option ("BoundingBoxLineWidth", "2")
  CommandApi.Do()

 'Show labels on the bounding box
  CommandApi.Option ("BoundingBoxShowLabels","True")
  CommandApi.Do()

 'Change the bounding box label font to Times New Roman
  CommandApi.Option ("BoundingBoxFont", "Times New Roman")
  CommandApi.Do()

 'Change the bounding box label size
  CommandApi.Option ("BoundingBoxLabelSize", "12")
  CommandApi.Do()

 'Change the bounding box label color to red
  CommandApi.Option ("BoundingBoxLabelColor", "Red")
  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.