Scripting not fully working in PLE version?

I’ve just started learning Animate Pro and it’s really really great!

However I am currently trying to create som scripts to make work easier. What I am currently trying to do is to create a script that can add keyframes and also get the data (like position) for a keyframe. The strange thing however is that nothing happens for some of the methods.

For example, this is some code that will not work:

function TestScript(){

column.setKeyFrame(“TopLayer”, 5);

MessageLog.trace(“Creating a key frame…”)
}

I get the “Creating a key frame…” debug trace showing in my MessageLog but no key frame is added. I have a layer named TopLayer. The same thing goes for methods like “column.clearKeyFrame(…)” etc.

I would also like to be able to get the keyframe values for things like “Position: Pos x” or “Pos y” (the same values that you see when clicking “Show Data View”, can this be done through scripting?

What can the reasons be that many of the methods for columns are not working? Is it because of a bug in my Animate Pro, is it because i am running PLE or what could it be? I am currently running Animate Pro 2 Version 7.9.1 (6016) on a Mac.

Thank you! /Johan

Tested this on a Windows computer running Toon Boom Studio 2 today. Same result, nothing happens.

Is it even possible to create keyframes and read keyframe values using scripting or is the scripting engine not fully supported anymore?

Is it possible someone in the Toon Boom team (Lily?) could verify if the script I posted above works on the latest Toon Boom version?

I think the most basics things like adding keyframes and reading the data from frames should be supported by scripting?

I will try to have a look at it if i get time, but have you tried running it with the xsheet as the active window.

One thing I have noticed is a lack of ability to move from one window to another in scripting. So for example I couldn’t draw, then change layers and draw some more.

I’m really sorry about the late response on this, I had someone look at it but I went on the road and have not had a chance yet to get back to you.

It is possible to add a keyframe to a column, but a column is different from a module, and you have to connect a column to a read module, and tell it exactly which function you want the keyframe to go on.

Rather than doing it that way, one of our programmers suggested an easier way. You have to select the modules first that you want to set the keyframes on, then you specify the functions in the script:

function testfk()
{
var n = selection.numberOfNodesSelected();
var i;
var a = new Array;
for( i =0 ; i< n ; ++i)
{
var s = selection.selectedNode(i);
MessageLog.trace(node.type(s));
if (node.type(s) == “READ” ||
node.type(s) == “PEG”)
{
MessageLog.trace(“push”);
a.push(s)
}
}
selection.clearSelection();
for(i=0 ; i< a.length ; ++i)
{
selection.addNodeToSelection(a);
}

MessageLog.trace(“Selection: " + selection.numberOfNodesSelected());

// The begin undo should be put after the selection has been rebuilt
scene.beginUndoRedoAccum(“My Command”);

Action.perform(“onActionSetKeyFrames()”);

for(i=0 ; i< a.length ; ++i)
{

var sep = node.getTextAttr(a, frame.current(), “offset.separate”);
MessageLog.trace(“sep “+ sep);
if (sep == “On”)
{
var val = node.getTextAttr(””, frame.current(), “offset.x”);
val += 5;
node.setTextAttr(a, “offset.x”, frame.current(), val);
}
else
{
var c = node.linkedColumn(a, “offset.attr3dpath”);
MessageLog.trace(“col: —” + c + “—”);
// subcol 1 = x axis
var val = column.getEntry(c, 1, frame.current());
val = val.replace(” ", “”);
if (val.find(“E”) >= 0)
{
val = val.replace(“E”, “”);
// This will convert the string to number
val *= 1;
}
else
{
val = val.replace(“W”, “”);
// This will convert the string to number
val *= -1;
}
val += 6;
MessageLog.trace(“new val: —” + val + “—”);
column.setKeyFrame(c, frame.current());
column.setEntry(c, 1, frame.current(), val);
}
}
scene.endUndoRedoAccum();
}