PaletteManager

This set of functions is used to query information from the Colour view. All of these are used.

The following is a list of the PaletteManager functions:

getCurrentColorId
getCurrentColorName
coordX
getCurrentPaletteName
setCurrentPaletteById
setCurrentColorById
setCurrentPaletteAndColorById
getCurrentPalettePath
getCurrentPaletteSize
getColorName
getColorId
getNumPalettes
getNumPalettes
getPaletteName
getPaletteName
getPalettePath
getPalettePath
getPaletteId
getPaletteId

Example

// An example of how to use the palette override attributes of the colour override module.

//

// Available attributes for getTextAttr:

// PALETTES.NUMBER - returns the number of palettes in the palette override list

// PALETTES.x, where x is a palette index - return the palette name (path) of the palette at index x (x >= 0)

// If no x, or it's invalid, assume a value of 0

//

// Available attributes for setTextAttr:

// PALETTES.CLEAR - clear the palette override list

// PALETTES.ADD "palette_path" - add the palette with full path name to the palette override list.

// Can supply the full path or get from

// PaletteManager.getPalettePath(), PaletteManager.getCurrentPalettePath()

// PALETTES.REMOVE "palette_path" - remove a palette.

// Can supply the full path or get from getTextAttr("node_path", atFrame, "PALETTES.x")

//

// Note that the frame number argument (to node.getTextAttr() and node.setTextAttr()) is unused, and the attribute value in

// "PALETTES.CLEAR" is unused.

//

function paletteOverrideExample()

{

if (selection.numberOfNodesSelected() != 1)

return;

// not strictly necessary, depends on whether each setTextAttr() call should be undoable individually

scene.beginUndoRedoAccum("Palette Overrides");

var module = selection.selectedNode(0);

// return the number of palettes in the palette override list

var num = node.getTextAttr(module, 1, "PALETTES.NUMBER");

// return the first (top-most) palette name in the palette override list (will be "" if the list is empty).

// note that no palette number is supplied in this example, so 0 is assumed (equivalent to "PALETTES.0")

var palette = node.getTextAttr(module, 1, "PALETTES");

// clear (empty) the list

node.setTextAttr(module, "PALETTES.CLEAR", 1, "");

// should be 0

num = node.getTextAttr(module, 1, "PALETTES.NUMBER");

// add a palette to the palette override list

var curpath = PaletteManager.getCurrentPalettePath();

node.setTextAttr(module, "PALETTES.ADD", 1, curpath);

// can also specify a full path for the palette

//node.setTextAttr(module, "PALETTES.ADD", 1, "/usadata000/.../example.plt");

// this should do nothing, already exists

//node.setTextAttr(module, "PALETTES.ADD", 1, "/usadata000/.../example.plt");

// return the first two palette names (we added one, so one should be non-empty)

palette = node.getTextAttr(module, 1, "PALETTES.0");

// this one should be "", only one in the list

var palette1 = node.getTextAttr(module, 1, "PALETTES.1");

// return the name of the last palette that we added

num = node.getTextAttr(module, 1, "PALETTES.NUMBER");

var index = parseInt(num);

index--;

var attr = "PALETTES." + index;

palette = node.getTextAttr(module, 1, attr);

// remove one from the list

node.setTextAttr(module, "PALETTES.REMOVE", 1, palette);

// can also specify a full path for the palette

//node.setTextAttr(module, "PALETTES.REMOVE", 1, "/usadata000/.../example.plt");

num = node.getTextAttr(module, 1, "PALETTES.NUMBER");

scene.endUndoRedoAccum();

}

Related Topics 

Scripting Reference