Scripting Nodes¶
Prerequisites¶
- The following methods are exposed by the NodeCreation, NodeControl and NodeSelection objects implemented by the module Thinkbox.Sequoia.Nodes
- Before calling these methods, you must ensure the module is imported.
import Thinkbox.Sequoia.Nodes 1.0
Node Creation¶
<string> NodeCreation.createPointLoader ( <string>defaultFile, <bool>promptFile )
- Creates a new Point Loader.
- The first argument defines the file name to use as the point data source. It can be an empty string.
- The second argumemt controls whether to prompt the user to pick a source file manually (true), or not (false).
<string> NodeCreation.createPointROI ( <string>nodeId )
- Creates a new Point Region Of Interest object.
- 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.
<string> NodeCreation.createMesher ( <string>nodeId, [ <bool>useSuggestedRadius=true ] )
- Creates a new Mesher object.
- The first 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.
- The second (optional) argument is a boolean value.
- If supplied as true, or not specified, the suggested radius calculated by the Mesher will be used.
- If supplied as false, the radius will not be set and has to be set by the script by modifying the Radius input, or by the user via the UI.
<string> NodeCreation.createMeshLoader ( <string>defaultFile, <bool>promptFile, <bool>autobuild )
- Creates a new Mesh Loader object.
- 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.
<string> NodeCreation.createTextureProjection ( <string>defaultFile, <bool>promptFile )
- Creates a new Image Projection object
- The first argument defines the file name to use as the image source. It can be an empty string.
- The second argumemt controls whether to prompt the user to pick an image file manually (true), or not (false).
<string> NodeCreation.createPointSurface ( <string>nodeId )
- Creates a new Surface Points object.
- The first and only argument defines the node handle of a source object - either a Mesher, or a Mesh Loader.
- 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.
Node Selection¶
<void> NodeSelection.setSelectedNode ( <string>nodeId )
- Sets the selection to the specified node.
- Any other selected nodes will be deselected automatically.
- The first and only argument is the ID of the node to select.
Example:
var a1 = NodeCreation.createPointLoader('', true); //create a Point Loader
var a2 = NodeCreation.createMesher(a1); // create a Mesher connected to it
//At this point, the Mesher would be selected
NodeSelection.setSelectedNode(a1); // select the Point Loader instead
<void> NodeSelection.addSelectedNode ( <string>nodeId )
- Selects the specified node, while retaining the existing selection.
- The first and only argument is the ID of the node to add to the selection.
Example:
var a1 = NodeCreation.createPointLoader('', true); //create a Point Loader
var a2 = NodeCreation.createMesher(a1); // create a Mesher connected to it
//At this point, the Mesher would be selected
NodeSelection.addSelectedNode(a1); // add the Point Loader to the selection
//At this point, both objects are selected
<void> NodeSelection.removeSelectedNode ( <string>nodeId )
- Deselects the specified node, while keeping the rest of the selected node in the selection set.
- The first and only argument is the ID of the node to remove from the selection.
<void> NodeSelection.clearSelectedNodes ( <string>documentId )
- Deselects all nodes in the specified Document.
- The first and only argument is the Document ID.
<stringList> NodeSelection.getSelectedSequoiaNodes ()
- Returns the selected nodes as a list of Node IDs.
Example:
//Manually select a Point Loader in the Document... then evaluate:
var s1 = NodeSelection.getSelectedSequoiaNodes(); //get the selected object
var d1 = DocumentContro.getCurrentDocument(); //get the current document
var response = NodeControl.getNodeProperty( d1, s1[0], "inFilename" ); //get the filename property of the first selected object
console.log( response ); //output the file name to the Log
Node Properties Access¶
<variant> NodeControl.getNodeProperty ( <string>documentId, <string>nodeId, <string>propertyName )
- Returns the value of the specified property in the given node and document.
- The type of the return value 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.
- The first argument specifies the Document ID.
- The second argument specifies the Node ID.
- The third argument provides the string with the name of the property to query.
Example:
var n0 = NodeCreation.createPointLoader('',true); //create a Point Loader, let the user pick the file name
var response = NodeControl.getNodeProperty( 0, n0, "inFilename" ); //get the file name
console.log( response ); //and output to the Log to see what the user picked...
<void> NodeControl.setNodeProperty ( <string>documentId, <string>nodeId, <string>propertyName, <Variable>value )
- Sets the value of the property in the given node and document to the provided value.
- The first argument specifies the Document ID.
- The second argument specifies the Node ID.
- The third argument provides the string with the name of the property to query.
<StringList> getAllNodePropertyNames ( <string>documentId, <string>nodeId )
- Returns all property names available in the specified node as a list of strings.
- The first argument specifies the Document ID.
- The second argument specifies the Node ID.
<Vector3D> getNodePosition ( <string>nodeId, [ <string>documentId ] )
- Returns the scene object’s world space Position.
- The first argument specifies the Node ID.
- The second, optional argument specifies the Document ID.
- If not specified, or if supplied as empty string, the current Document will be used implicitly.
- Available in Sequoia v1.0.27 and higher.
<><Quaternion> getNodeOrientation ( <string>nodeId, [ <string>documentId ] );
- Returns the scene object’s world space Orientation.
- The first argument specifies the Node ID.
- The second, optional argument specifies the Document ID.
- If not specified, or if supplied as empty string, the current Document will be used implicitly.
- Available in Sequoia v1.0.27 and higher.
<Vector3D> getNodeScale ( <string>nodeId, [ <string>documentId ] );
- Returns the scene object’s world space Scale.
- The first argument specifies the Node ID.
- The second, optional argument specifies the Document ID.
- If not specified, or if supplied as empty string, the current Document will be used implicitly.
- Available in Sequoia v1.0.27 and higher.
<void> setNodePosition ( <Vector3D>position, <String>nodeId, [ <String>documentId ] );
- Sets the scene object’s world space Position to the first argument.
- The second argument specifies the Node ID.
- The third, optional argument specifies the Document ID.
- If not specified, or if supplied as empty string, the current Document will be used implicitly.
- Available in Sequoia v1.0.27 and higher.
<void> setNodeOrientation ( <Quaternion>orientation, <String>nodeId, [ <String>documentId ] );
- Sets the scene object’s world space Orientation to the first argument.
- The second argument specifies the Node ID.
- The third, optional argument specifies the Document ID.
- If not specified, or if supplied as empty string, the current Document will be used implicitly.
- Available in Sequoia v1.0.27 and higher.
<void> setNodeScale ( <Vector3D>scale, <String>nodeId, [ <String>documentId ] );
- Sets the scene object’s world space Scale to the first argument.
- The second argument specifies the Node ID.
- The third, optional argument specifies the Document ID.
- If not specified, or if supplied as empty string, the current Document will be used implicitly.
- Available in Sequoia v1.0.27 and higher.
Example:
var sel = NodeSelection.getSelectedSequoiaNodes(); //get the selected objects
var i = 0;
for (i = 0; i < sel.length; i++) {
var pos = NodeControl.getNodePosition ( sel[i] ); //get the i-th node's position
pos.x += 1.0; //move the object 1 meter along X
NodeControl.setNodePosition ( pos, sel[i] ); // set the position of the node
}