Follow

How can I change the lighting in my Voxler project via automation?

This article contains a sample script for opening an existing Voxler file, adding a Light module and changing all the properties of the Light module.

To run this script:

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

*********

'********************************************************************************************
' LightModule.bas
' This script opens an existing Voxler file and adds a light module.
' It then changes all the properties of the light module.
'********************************************************************************************

' 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 light module
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("Type", "Light")
  CommandApi.Do()

 'Set the light type
 'This is either 0, 1, or 2 for directional, point, or spot light
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option("Module", "Light")
  CommandApi.Option ("LightType", "2")
  CommandApi.Do()

 'Change the light color
  CommandApi.Option ("LightColor", "Soft Pink")
  CommandApi.Do()

 'Show the light dragger
  CommandApi.Option ("LightDragger", "True")
  CommandApi.Do()

 'Set the Light X direction
 'Available where lighttype is 0 or 2
  CommandApi.Option ("LightXDirection", "-0.3191513419")
  CommandApi.Do()

 'Set the light Y direction
 'Available where lighttype is 0 or 2
  CommandApi.Option ("LightYDirection", "-0.01555646956")
  CommandApi.Do()

 'Set the light Z direction
 'Available where lighttype is 0 or 2
  CommandApi.Option ("LightZDirection", "-0.947576046")
  CommandApi.Do()

 'Set the light X position
 'Available where lighttype is 1 or 2
  CommandApi.Option ("LightXPosition", "2186.218803")
  CommandApi.Do()

 'Set the light Y position
 'Available where lighttype is 1 or 2
  CommandApi.Option ("LightYPosition", "1298.90401")
  CommandApi.Do()

 'Set the light Z position
 'Available where lighttype is 1 or 2
  CommandApi.Option ("LightZPosition", "2497.27057")
  CommandApi.Do()

 'Set the light cutoff value
 'Available where lighttype is 2
  CommandApi.Option ("LightCutoff", "30")
  CommandApi.Do()

 'Set the light drop off value
 'Available where lighttype is 2
  CommandApi.Option ("LightDropoff", "0.8")
  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.