Node Store

8 votes
Date Updated: 

In Max6 'this' has been added to the script controllers making it posible to reference the script controller itself. This means you can now use a Custom Attribute added to the script controller and store the nodes that the script will be accessing. Why you ask? Well up to now script controllers have had two major flaws. Speed - and a dependency on the names of the objects that are referenced in them. Both problems were taken care of at the same time with the addition of 'this' The following script aids on working with CA's on scripted controllers and makes it painless to set up.

No longer needed in Max 8

Additional Info: 

Select any track and change it to a script controller. In the case shown it is the position controller that is being used.

Make sure that the controller track is selected and trackview is left open.

Run the Macro Script 'Open Node Store' and this dialog will open. It will also open the script controller if the window is not already displayed.

Node Handle: This is where you enter a unique name that will reference the node that you are going to store.
Add Node: Once a node handle name is typed in push this button then click on the node that you want to store.
Delete Node: This will delete the selected node in the Node List.
Node List: List of all the currently stored nodes. Displayed is the index of the node in the array - the unique node handle and then the nodes name in Max.
Copy: Will copy all the nodes and the script depending on the checkboxes below.
Paste: Will paste the copied nodes and the script depending on the checkboxes below.

The script can be written in to different ways. The first uses the node handle - the second references the node directly.

First Method:
this.ns.node #Con1
'this' refers to the script controller.
'ns' refers to the custom attribute that stores the nodes.
'node' calls the function that will search for the correct node handle.
'#Con1' in this case is the given node handle
This method is the slowest between the two since the node handle needs to be searched for. The more nodes in the list the slower the search might be. I have tested the speed with up to 10 node handles and have not seen a slow down that would stop me from using this method. The search has been optomized as best as possible to keep it fast.
This method has the advantage that if the node list is changed it will not break the script - unless the node that is deleted is referenced in the script ofcourse.

Seccond Method:
'this' refers to the script controller.
'ns' refers to the custom attribute that stores the nodes.
'nodes[1]' references the array that the nodes are stored in thier order added and displayed in the node list. In this case the 1st node is being referenced.
This method is the fastest since the node handle doesn't need to be searched for but has the problem that if the node lists order changes the script will not be valid and an error will be thrown. The order will change if a node is delete from the list higher up forcing the array to renumber the remaining entries.

Open the zip file and copy to the scriptsstartup forlder and PEN_nodeStore.mcr to the uimacroScripts folder and restart Max. Max6 or higher must be used for this script.

Tips: is a struct and the functions can be accessed and added to you own code.
nS=nodeStore(): Create an instance of the struct. Runs nodeStore and adds it to a selected track that is a script controller.
nS.openCaDialog(): Opens the nodeStore dialog box and script. The track must be selected in trackview.
.ns.node: Access to the node handle function. This takes one argument which is the node handle to be accessed <#Con1>.
.ns.nodes: Access to the array that stores the nodes. The length of this array must be kept the same length of the names array.
.ns.names: Access to the array of node handles as strings. The length of the names array must remain the same length as the nodes array.

Version Requirement: 
8; 7; 6
Video URL: