Introduction To Scripting

Overview

  • Sequoia supports QML - Qt’s markup language - for quick description of User Interface layouts.
  • Within QML, JavaScript is currently used as the scripting language which can also execute Sequoia-specific commands.

JavaScript Syntax

Sequoia Modules Import

  • Sequoia provides several modules implementing objects which in turn expose methods related to different areas of the application.
import Thinkbox.Sequoia.Nodes 1.0
import Thinkbox.Sequoia.Documents 1.0
import Thinkbox.Sequoia.Conversion 1.0

Converting Point Files

  • To convert a point file from a supported source file format to a supported target file format, the script must first import the Thinkbox.Sequoia.Conversion module which implements the ImportExport object.
import Thinkbox.Sequoia.Conversion 1.0
  • The method convertPointFile() exposed by the ImportExport object will convert the specified source file to the specified tagret file:
ImportExport.convertPointFile ( <string>sourcefile, <string>targetfile )
  • The first argument is the full filename of the source point data file.
  • The second argument is the full filename of the target point data file.

Creating Objects

  • To create scene objects, the script must first import the Thinkbox.Sequoia.Nodes module which implements the NodeCreation object:
import Thinkbox.Sequoia.Nodes 1.0
  • Then, the corresponding creation method exposed by the NodeCreation object can be called:

Creating A Point Loader

  • To create a Point Loader, the script must call the createPointLoader() method in the NodeCreation object:
<nodeHandle>NodeCreation.createPointLoader( <filename>sourceFile , <bool>promptFile )
  • The first argument is the file name to load - if can be passed as empty string if no file should be loaded by the script.
  • The second argument controls whether the Point Loader should prompt the user to pick a file name interactive using a file dialog.

Creating A Point Region Of Interest

  • To create a Point Region Of Interest, the script must call the createPointROI() method in the NodeCreation object:
<nodeHandle>NodeCreation.createPointROI( <node>source )
  • The first and only argument defines the node handle of a source object - either a Point Loader, or another Point Region Of Interest.
  • The argument can be passed as undefined to create an object without a connection.
  • To connect multiple input sources, you must set the sources input property after the object is created.

Creating A Mesher

  • To create a Mesher, the script must call the createMesher() method in the NodeCreation object:
<nodeHandle>NodeCreation.createMesher( <node>source  )
  • The first and only argument defines the node handle of a source object - either a Point Loader, or a Point Region Of Interest.
  • The argument can be passed as undefined to create an object without a connection.
  • To connect multiple input sources, you must set the sources input property after the object is created.

Creating A Mesh Loader

  • To create a Mesh Loader, the script must call the createMeshLoader() method in the NodeCreation object:
<nodeHandle>NodeCreation.createMeshLoader( <filename>sourceFile, <bool>promptFile, <bool>autoBuild  )
  • The first argument is the file name to load - if can be passed as empty string if no file should be loaded by the script.
  • The second argument is a boolean flag controlling whether to prompt the user to pick a file manually.
    • When passing an empty string as the file name, you might want to set the second argument to true.
    • When passing a valid file name as the first argument, the second argument should be set to false.
  • The third argument is a boolean flag that controlling whether to auto-update the object after creation.

Property Access

  • Getting and setting node properties currently requires the Document as argument.
  • Usually, the crrent Document is acquired using
var document = DocumentControl.getCurrentDocument();

Getting The Current Document

  • To get the current document, the script must first import the Thinkbox.Sequoia.Document module which implement the DocumentControl object:

For example

import Thinkbox.Sequoia.Documents 1.0

var document = DocumentControl.getCurrentDocument();
  • The method getCurrentDocument() exposed by the DocumentControl object will return the handle of the current document.
  • The return result can be stored in a variable to pass to methods that require the document as argument.

Getting A Node Property

  • The method getNodeProperty() exposed by the NodeControl object implemented by the Thinkbox.Sequoia.Nodes module returns the named node property of a specified node in a specified document.
<result>NodeControl.getNodeProperty ( <document>, <node>, <propertyNameString> )
  • The first argument is the Document containing the node.
  • The second argument is the Node handle.
  • The third argument is the string containing the name of the property to query.
  • The return value is the value of the property - type will depend on the property’s value type.
  • Note that JavaScript variables are type-free, so any value would be accepted if assigned to a variable.

For example:

import Thinkbox.Sequoia.Documents 1.0 // needed to access documents
import Thinkbox.Sequoia.Nodes 1.0 //needed to create and access document's nodes

var node0 = NodeCreation.createPointLoader( "" , true ); //create a Point Loader, prompt the user to pick a file
var document = DocumentControl.getCurrentDocument(); //get the current document
var filename = NodeControl.getNodeProperty( document, node0, "inFilename" ); //get the filename the user picked

Setting A Node Property

  • The method setNodeProperty() exposed by the NodeControl object implemented by the Thinkbox.Sequoia.Nodes module sets the named node property of a specified node in a specified document to the given value.
NodeControl.setNodeProperty (<document>, <node>, <propertyNameString>, <newValue> )

* The first argument is the Document containing the node.
* The second argument is the Node handle.
* The third argument is the string containing the name of the property to query.
* The last argument is the new value, where the type must match the type of the property.

Logging Results To The Console

  • Normally, all STD output of the scripting language will be redirected to the Sequoia Log.
  • Additional custom output can be sent to the Log using the console.log() method.

For example:

// see the previous example
var filename = NodeControl.getNodeProperty( document, node0, "inFilename" );
console.log( "Filename is " + filename );