Follow

How can I rotate my view in Voxler using a script?

This article contains a sample script for loading an existing VOXB file and changing the view rotations.

To run this script:

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

********* 

'********************************************************************************************
' ViewerPosition.bas
' This script loads an existing VOXB file and changes the view rotations.
'********************************************************************************************

' 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 text showing the orientation
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("Type", "Annotation")
  CommandApi.Do()

 'Modify the text
  CommandApi.Construct("ModifyModule")
  CommandApi.Option ("Module", "Annotation")
  CommandApi.Option ("AnnotationText", "Left")
  CommandApi.DoOnce()

 'Change the Viewer direction to Left
  CommandApi.Construct("ViewDirection")
  CommandApi.Option ("ViewDirection", "Left")
  CommandApi.Do()

 'Wait 3 seconds
  Wait(3)

 'Change the Viewer direction to Top
  CommandApi.Construct("ViewDirection")
  CommandApi.Option ("ViewDirection", "Top")
  CommandApi.Do()

 'Update the annotation
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Annotation")
  CommandApi.Option ("AnnotationText", "Top")
  CommandApi.DoOnce()

 'Wait 3 seconds
  Wait(3)

 'Change the Viewer direction to Right
  CommandApi.Construct("ViewDirection")
  CommandApi.Option ("ViewDirection", "Right")
  CommandApi.Do()

 'Update the annotation
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Annotation")
  CommandApi.Option ("AnnotationText", "Right")
  CommandApi.DoOnce()

 'Wait 3 seconds
  Wait(3)

 'Change the Viewer direction to Bottom
  CommandApi.Construct("ViewDirection")
  CommandApi.Option ("ViewDirection", "Bottom")
  CommandApi.Do()

 'Update the annotation
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Annotation")
  CommandApi.Option ("AnnotationText", "Bottom")
  CommandApi.DoOnce()

 'Wait 3 seconds
  Wait(3)

 'Change the Viewer direction to Front
  CommandApi.Construct("ViewDirection")
  CommandApi.Option ("ViewDirection", "Front")
  CommandApi.Do()

 'Update the annotation
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Annotation")
  CommandApi.Option ("AnnotationText", "Front")
  CommandApi.DoOnce()

 'Wait 3 seconds
  Wait(3)

 'Change the Viewer direction to Back
  CommandApi.Construct("ViewDirection")
  CommandApi.Option ("ViewDirection", "Back")
  CommandApi.Do()

 'Update the annotation
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Annotation")
  CommandApi.Option ("AnnotationText", "Back")
  CommandApi.DoOnce()

 'Wait 3 seconds
  Wait(3)

 'Change the Viewer direction to Default
  CommandApi.Construct("ViewDirection")
  CommandApi.Option ("ViewDirection", "Default")
  CommandApi.Do()

 'Update the annotation
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Annotation")
  CommandApi.Option ("AnnotationText", "Default")
  CommandApi.DoOnce()

 'Sets the view so that the objects in the viewer window fit the screen size
  CommandApi.Construct ("ViewFittoWindow")
  CommandApi.Do()

 'Sets the viewer window size
  CommandApi.Construct("ViewSize")
  CommandApi.Option ("XSize", "500")
  CommandApi.Option ("YSize", "500")
  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.