All posts by Clinton Reese

Saving and Loading Toolbars

If you try to save a toolbar to disk it will save as empty without any buttons. Workaround is to create the toolbar in the Toolbar Prototypes Encapsulator then save the Toolbar Prototypes Encapsulator to disk. Reload into trueSpace in a different location and remove all the toolbars except for the toolbar of interest, optionally rename the encapsulator and save to disk. Now loading this encapsulated toolbar won’t loose the buttons.

trueSpace Toolbar Button Bug?

When a script is called from a toolbar button using ScriptObject.Execute, the script will not be able to read node connection values, Node.Value If the same script is called from a toolbar button using Activity.Run then it can read the values without an error.

As noted in another post the Node.Value will also fail inside a script function set. The fix is to use RsApp.RunScriptBuffer

GlobalFS = Node.AccessFnSet("Scripts/CustomCommands/Global Function Set");GlobalFS.Parent();

will fail when run from a toolbar button because GlobalFS.Parent() has a Node.Value in it.

cmd='GlobalFS = Node.AccessFnSet("Scripts/CustomCommands/Global Function Set");GlobalFS.Parent();';RsApp.RunScriptBuffer(cmd);

wrapped in a script buffer command and it works

Truespace Script Buffer

trueSpace scripts create an undo step for each command in the script that changes the graph. So a single script can have many undo steps generated. The trueSpace script buffer will run a collection of script commands in the form of a string and generate only 1 undo.

Function Set variables can be used to pass complex data structures to the buffer.

If Node.Value() is used inside of a function set then it cannot be called directly from a toolbar button. The Node object seems to be incomplete and will fail with an warning message in the log, but no alert dialog like normal errors. If called using the script buffer command the Node.Value function will work when called from a toolbar button.

var cmd = ''
// note that if System.ThisOwner() is included in the buffer tS will crash
var thisowner = System.ThisOwner()
cmd += var owner = "' + thisowner + '";'
cmd += 'System.Trace(owner)'
RsApp.RunScriptBuffer(cmd);

trueSpace Delete Bug

When selected items are deleted the Node commands still behave as if the selection exists. Code below shows how to check for a valid selection before using it.

// Execute 
// Called to execute the command 
function Execute(params)
{
    if(!IsValidSelection(Node.Selection())) return;
    System.Trace("selection is good");
}
function IsValidSelection(selection)
{
    if(!selection) return false;
    var reWhiteSpace = /^\s/; // whitespace in first character
    var selectionArray = selection.split(";");
    for(var i = 0; i < selectionArray.length; i++) {
        var selClean = selectionArray[i].replace(reWhiteSpace, "");
        if(!Node.Exists(selClean)) {
            return false;
        }
    }
    return true;
}

trueSpace script params

function Execute(params)
{
	var controlIn1 = params.ConValue('controlIn1');
	var controlIn2 = params.ConValue('controlIn2');

	var scriptFrom = params.GetControlIn();

	System.Trace(scriptFrom);

	if(scriptFrom == "controlIn2")
		params.SetControlOut("ControlOut2")
	else
		params.SetControlOut("ControlOut1")

	// params.ConValue("controlOut1") = ...
	// params.ConValue("ControlOut2") = ...
}

params.GetControlIn() gets the name of the control input that runs the script, so can have several input controls and make code decisions based on which input was used
params.SetControlOut(str) does the opposite and lets you choose which output control will fire off

params.SetTerminationFlag() will stop all downstream execution

params.GetControlIn() does not work, so this whole idea is dead

Random trueSpace Notes

The script command Physics.Impulse has max XYZ values of 100. Higher values are ignored. This command only has a small effect on the object motion.

When working with script combined with the axis tool always flatten the axis back into the geometry.

The saturate node for materials does not load into trueSpace. It just gives an error.

RsApp.Help() command needs the xslt file found in the home directory in order to view the resulting xml files properly.

IK locks and IK handles attach to bones, not to joints.

A jscript object cannot properly read changes to a universal array connector if was changed from outside by a command script.

The params object can be used to stop down stream execution of command scripts via params.SetTerminationFlag()

When editing a morph target it seems best to set mesh editor auto triangulation setting to “None” .

Linear interpolation works best for IK skeletons to prevent sliding.

Space.Unselect() command will change 3D selection behavior. Before run 3D view select will select members of a 2D group. After run the 2D group will be selected instead of one of it’s 3D members.

Rough Node Connector Notes

OnLoadDefault – not in script

OnDefaultValue – called when connector is created, maybe can use to save copy of default value of conn to read later

OnSetValue – object node only, called before value is saved on connector. after value is set all connected connectors will be set “invalid”

OnInvalidate – do something if marked as invalid

OnGetValue – object node only, for intensive calculations, is run only when value is requested not when any input changes(OnComputeInputs)

Activity.ToggleAutoRun(source node, enable) – enable false is off, enable true is toggle on/off? for command node only

Space.AutoRunActivities() will run all nodes that are setup with autorun, setup via ToggleAutoRun command or LMB hold icon of the command node and choose “Run automatically”

RtNotifyEvents travel up encapsulation tree to the rootnode, event can be captured by encaps coding

Commands can be run simultaneous shared mode if nothing in the graph changes – no evidence of this since almost everything I write will change the graph. Need test on some pure intensive calculations see if can run parallel (simultaneous shared mode ?== parallel)