Follow

How can I create an Isosurface in Voxler via automation?

This article contains a sample script for loading a data file, adding a Gridder module to it, adding an Isosurface to the Gridder module, and changing all the properties of the Isosurface.

To run this script:

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

*********

'********************************************************************************************
' IsosurfaceModule.bas
' This script loads a data file and adds a gridder module to it.
' It adds an isosurface to the gridder module.
' It then changes all the properties of the isosurface.
'********************************************************************************************

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

 'Load the data file
  CommandApi.Construct("Import")
  CommandApi.Option ("Path", VoxlerApp.Path+"\Samples\GoldConcentration.dat")
  CommandApi.Option ("Filter", "dat")
  CommandApi.Option ("Options", "Defaults=1;EatWhitespace=1;Delimiter=Space,tab,comma,semicolon;TextQualifier=doublequote,quote")
  CommandApi.Option ("GuiEnabled", "False")
  CommandApi.Do()

 'Add a gridder module
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "GoldConcentration.dat")
  CommandApi.Option ("Type", "Gridder")
  CommandApi.Do()

 'Grid the data
  CommandApi.Construct("ModifyModule")
  CommandApi.Option("Module","Gridder")
  CommandApi.Option("Gridder3Auto", "true")
  CommandApi.Option("Gridder3DoIt", "true")
  CommandApi.Do()

 'Add a isosurface module
  CommandApi.Construct("CreateModule")
  CommandApi.Option ("AutoConnect", "True")
  CommandApi.Option ("SourceModule", "Gridder")
  CommandApi.Option ("Type", "Isosurface")
  CommandApi.Do()

 'Change the isosurface component
  CommandApi.Construct ("ModifyModule")
  CommandApi.Option ("Module", "Isosurface")
  CommandApi.Option ("IsoSurfaceComponent", "1")
  CommandApi.Do()

 'Change the isosurface drawing style
 'This is a number 0, 1, or 2
 '0 indicates shaded, 1 is lines only, and 2 is points
  CommandApi.Option ("IsoSurfaceDrawstyle", "1")
  CommandApi.Do()

 'Change the isosurface "Side to Draw" style
 'This is a number 0, 1, or 2
 '0 indicates front and back, 1 is front only, and 2 is back only
  CommandApi.Option ("IsoSurfaceFacestyle", "2")
  CommandApi.Do()

 'Change the isosurface "Side to Draw" style
  CommandApi.Option ("IsoSurfaceNormals", "true")
  CommandApi.Do()

 'Change the isosurface isovalue
  CommandApi.Option ("IsoSurfaceIsovalue", "3.9")
  CommandApi.Do()

 'Change the coloring of the isosurface to a fixed color
 '0 = fixed, 1 = by data
  CommandApi.Option ("IsoSurfaceColorMethod", "0")
  CommandApi.Do()

 'Change the fixed color to light green
  CommandApi.Option ("IsosurfaceColor", "light green")
  CommandApi.Do()

  Wait (2)

 'Change the isosurface drawing style
 'This is a number 0, 1, or 2
 '0 indicates shaded, 1 is lines only, and 2 is points
  CommandApi.Option ("IsoSurfaceDrawstyle", "0")
  CommandApi.Do()

 'Change the coloring of the isosurface to a fixed color
 '0 = fixed, 1 = by data
  CommandApi.Option ("IsoSurfaceColorMethod", "1")
  CommandApi.Do()

 'Change the color map to rainbow
  CommandApi.Option ("IsosurfaceColormap", "Rainbow")
  CommandApi.Do()

 'Change the isosurface specular color
  CommandApi.Option ("IsoSurfaceSpecularColor", "magenta")
  CommandApi.Do()

 'Change the isosurface Specular Intensity - value between 0 and 1
  CommandApi.Option ("IsoSurfaceSpecularIntensity", "0.3")
  CommandApi.Do()

 'Change the IsoSurface Shininess  - value between 0 and 1
  CommandApi.Option ("IsoSurfaceShininess", "0.7")
  CommandApi.Do()

 'Change the IsoSurface Opacity  - value between 0 and 1
  CommandApi.Option ("IsoSurfaceOpacity", "0.4")
  CommandApi.Do()

 'Display the Isosurface legend
  CommandApi.Option ("IsosurfaceLegendEnable", "True")
  CommandApi.Do()

 'Change the legend orientation
 '0 is for horizontal, 1 is for vertical
  CommandApi.Option ("IsosurfaceLegendOrientation", "0")
  CommandApi.Do()

 'Change the legend X position
 'Ranges from 0-1
  CommandApi.Option ("IsosurfaceLegendXPos", "0.3")
  CommandApi.Do()

 'Change the legend Y position
 'Ranges from 0-1
  CommandApi.Option ("IsosurfaceLegendYPos", "0.9")
  CommandApi.Do()

 'Change the legend width
 'Ranges from 0-200
  CommandApi.Option ("IsosurfaceLegendWidth", "20")
  CommandApi.Do()

 'Change the legend length
 'Ranges from 0-1024
  CommandApi.Option ("IsosurfaceLegendLength", "400")
  CommandApi.Do()

 'Change the legend title
  CommandApi.Option ("IsosurfaceLegendTitle", "Legend Title")
  CommandApi.Do()

 'Change the legend title font size
 'Ranges from 4-72
  CommandApi.Option ("IsosurfaceLegendTitleHeight", "20")
  CommandApi.Do()

 'Change the number of labels displayed in a legend
  CommandApi.Option ("IsosurfaceLegendNumLabels", "3")
  CommandApi.Do()

 'Change the legend to use custom labels
  CommandApi.Option ("IsosurfaceLegendUseCustomLabels", "True")
  CommandApi.Do()

 'Set the custom labels for the legend
  CommandApi.Option ("IsosurfaceLegendCustomLabels", "1.7:low, 2.1:medium, 2.9:intermediate, 3.2:elevated, 3.7:high")
  CommandApi.Do()

 'Set the height for the legend labels
  CommandApi.Option ("IsosurfaceLegendLabelHeight", "8")
  CommandApi.Do()

 'Set the label format type for the legend
  CommandApi.Option ("IsosurfaceLabelFormatType", "0")
  CommandApi.Do()

 'Set the number of digits to display on the labels
  CommandApi.Option ("IsosurfaceLabelFormatNumDigits", "2")
  CommandApi.Do()

 'Set the legend label prefix
  CommandApi.Option ("IsosurfaceLabelFormatPrefix", "pre-")
  CommandApi.Do()

 'Set the legend label postfix
  CommandApi.Option ("IsosurfaceLabelFormatPostfix", "-post")
  CommandApi.Do()

 'Set the legend font
  CommandApi.Option ("IsosurfaceLegendFont", "Arial")
  CommandApi.Do()

 'Turn on or off antialiasing for the legend
  CommandApi.Option ("IsosurfaceLegendAntialias", "True")
  CommandApi.Do()

 'Set the line and text color for the legend
  CommandApi.Option ("IsosurfaceLegendFGColor", "Blue")
  CommandApi.Do()

 'Set the background color for the legend
  CommandApi.Option ("IsosurfaceLegendBGColor", "10% Gray")
  CommandApi.Do()

 'Turn on or off the display of the legend background
  CommandApi.Option ("IsosurfaceLegendShowBackground", "True")
  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.