Attribute Class Reference

The JavaScript class encapsulating a node attribute. Obtain one from the node getAttr or getAttrList methods. More...

Public Slots

virtual String keyword ()
 The keyword associated with the Attribute. More...
 
String name ()
 The name of the Attribute. More...
 
virtual String typeName ()
 The typeName value associated with the Attribute type. More...
 
virtual bool boolValue ()
 Fetches the boolean value from the Attribute at the current frame. More...
 
virtual int intValue ()
 Fetches the integer value from the Attribute at the current frame. More...
 
virtual double doubleValue ()
 Fetches the double value from the Attribute at the current frame. More...
 
virtual String textValue ()
 Fetches the String value from the Attribute at the current frame. More...
 
virtual ColorRGBA colorValue ()
 Fetches the ColorRGBA value from the Attribute at the current frame. More...
 
virtual Point2d pos2dValue ()
 Fetches the Point2d value from the Attribute at the current frame. More...
 
virtual Point3d pos3dValue ()
 Fetches the Point3d value from Attribute at current frame. More...
 
virtual bool boolValueAt (double frame)
 Fetches the boolean value from the Attribute at the specified frame. More...
 
virtual int intValueAt (double frame)
 Fetches the integer value from the Attribute at the specified frame. More...
 
virtual double doubleValueAt (double frame)
 Fetches the double value from the Attribute at the specified frame. More...
 
virtual String textValueAt (double frame)
 Fetches the String value from the Attribute at the specified frame. More...
 
virtual ColorRGBA colorValueAt (double frame)
 Fetches the ColorRGBA value from the Attribute at the specified frame. More...
 
virtual Point2d pos2dValueAt (double frame)
 Fetches the Point2d value from the Attribute at the specified frame. More...
 
virtual Point3d pos3dValueAt (double frame)
 Fetches the Point3d value from the Attribute at the specified frame. More...
 
virtual void setValue (QObject value)
 Sets the value of the Attribute. More...
 
virtual void setValue (int value)
 Sets the value of the Attribute. More...
 
virtual void setValue (double value)
 Sets the value of the Attribute. More...
 
virtual void setValue (bool value)
 Sets the value of the Attribute. More...
 
virtual void setValue (String &value)
 Sets the value of the Attribute. More...
 
virtual void setValueAt (QObject value, double frame)
 
virtual void setValueAt (int value, double frame)
 
virtual void setValueAt (double value, double frame)
 
virtual void setValueAt (bool value, double frame)
 
virtual void setValueAt (String &value, double frame)
 
QList< Attribute * > getSubAttributes ()
 Returns a list of the sub attributes of the Attribute. More...
 
bool hasSubAttributes ()
 Returns true if the Attribute has sub attributes. More...
 
String fullKeyword ()
 Return the full keyword of the Attribute. More...
 

Detailed Description

The JavaScript class encapsulating a node attribute. Obtain one from the node getAttr or getAttrList methods.

This class is polymorphic and can be used to handle multiple types as long as they are compatible with the initial attribute.

Member Function Documentation

◆ boolValue

virtual bool Attribute::boolValue ( )
virtualslot

Fetches the boolean value from the Attribute at the current frame.

This example prints just the boolean values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "BOOL")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
MessageLog.trace(wAttr.boolValue());
}
}
}
Returns
The boolean value, or false if it cannot be cast to a bool.

◆ boolValueAt

virtual bool Attribute::boolValueAt ( double  frame)
virtualslot

Fetches the boolean value from the Attribute at the specified frame.

This example prints just the boolean values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "BOOL")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
//frame.current() is used here making it functionally identical to wAttr.boolValue()
MessageLog.trace(wAttr.boolValueAt(frame.current()));
}
}
}
Parameters
frame: The frame number.
Returns
The boolean value, or false if it cannot be cast to a bool.

◆ colorValue

virtual ColorRGBA Attribute::colorValue ( )
virtualslot

Fetches the ColorRGBA value from the Attribute at the current frame.

This example sets the colour value of a colour card to a bright green, and prints the new colour value.

function greenColorCard()
{
var sNode = selection.selectedNode(0);
if (node.type(sNode) == "COLOR_CARD")
{
var myAttr = node.getAttrList(sNode, frame.current(), "");
var myColor = new ColorRGBA(86,255,0,255);
for(i=0; i < myAttr.length; i++)
{
if(myAttr[i].typeName() == "COLOR")
{
myAttr[i].setValue(myColor);
MessageLog.trace(myAttr[i].colorValue());
}
}
}
}
Returns
The ColorRGBA value, or (255,255,255,255) if it cannot be cast to a ColorRGBA object.

◆ colorValueAt

virtual ColorRGBA Attribute::colorValueAt ( double  frame)
virtualslot

Fetches the ColorRGBA value from the Attribute at the specified frame.

This example sets the colour value of a colour card to a bright green, and prints the new colour value.

function greenColorCard()
{
var sNode = selection.selectedNode(0);
if (node.type(sNode) == "COLOR_CARD")
{
var myAttr = node.getAttrList(sNode, frame.current(), "");
var myColor = new ColorRGBA(86,255,0,255);
for(i=0; i < myAttr.length; i++)
{
if(myAttr[i].typeName() == "COLOR")
{
myAttr[i].setValue(myColor);
//frame.current() is used here, making it functionally identical to myAttr[i].colorValue()
}
}
}
}
Parameters
frame: The frame number.
Returns
The ColorRGBA value, or (255,255,255,255) if cannot be cast to a ColorRGBA object.

◆ doubleValue

virtual double Attribute::doubleValue ( )
virtualslot

Fetches the double value from the Attribute at the current frame.

This example prints just the double values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "DOUBLE")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
MessageLog.trace(wAttr.doubleValue());
}
}
}
Returns
The double value, or 0.0 if it cannot be cast to a double.

◆ doubleValueAt

virtual double Attribute::doubleValueAt ( double  frame)
virtualslot

Fetches the double value from the Attribute at the specified frame.

This example prints just the double values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "DOUBLE")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
//frame.current() is used here making it functionally identical to wAttr.doubleValue()
MessageLog.trace(wAttr.doubleValueAt(frame.current()));
}
}
}
Parameters
frame: The frame number.
Returns
The double value, or 0.0 if it cannot be cast to a double.

◆ fullKeyword

String Attribute::fullKeyword ( )
slot

Return the full keyword of the Attribute.

If the Attribute has a parent attribute, the full keyword will include it, where just keyword() will not.

Full keywords are of the form "Parent.SubAttribute", whereas the keyword would be "SubAttribute".

Returns
The full keyword of the Attribute.

◆ getSubAttributes

QList<Attribute*> Attribute::getSubAttributes ( )
slot

Returns a list of the sub attributes of the Attribute.

Sub attributes, or child attributes, are of the form "PARENT.CHILD", such as "POSITION.X".

Returns
A list of the sub attributes of the Attribute.

◆ hasSubAttributes

bool Attribute::hasSubAttributes ( )
slot

Returns true if the Attribute has sub attributes.

This example prints the attributes of a drawing node that have sub attributes.

function printHasSubAttributes()
{
var sNode = selection.selectedNode(0);
if (node.type(sNode) == "READ")
{
var myAttr = node.getAttrList(sNode, frame.current(), "");
for(i=0; i < myAttr.length; i++)
{
if(myAttr[i].hasSubAttributes())
{
MessageLog.trace("The attribute \"" + myAttr[i].name() + "\" has at least one sub attribute.");
}
}
}
}
Returns
Returns true if the Attribute has sub attributes, false if not.

◆ intValue

virtual int Attribute::intValue ( )
virtualslot

Fetches the integer value from the Attribute at the current frame.

This example prints just the integer values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "INT")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
MessageLog.trace(wAttr.intValue());
}
}
}
Returns
The integer value, or 0 if it cannot be cast to an int.

◆ intValueAt

virtual int Attribute::intValueAt ( double  frame)
virtualslot

Fetches the integer value from the Attribute at the specified frame.

This example prints just the integer values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "INT")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
//frame.current() is used here making it functionally identical to wAttr.intValue()
MessageLog.trace(wAttr.intValueAt(frame.current()));
}
}
}
Parameters
frame: The frame number.
Returns
The integer value, or 0 if it cannot be cast to an int.

◆ keyword

virtual String Attribute::keyword ( )
virtualslot

The keyword associated with the Attribute.

This example returns a list of all the attributes of a node, including all the sub attributes.

function getFlatAttrList(sNode, sAttr)
{
var subAttrs = node.getAttrList(sNode, frame.current(), sAttr);
if(subAttrs.length==0)
return [sAttr];
var subAttrList = [];
for(var i=0; i<subAttrs.length; i++)
{
var subAttrKeyword = (sAttr===undefined)?subAttrs[i].keyword()
:sAttr+"."+subAttrs[i].keyword();
subAttrList = subAttrList.concat(getFlatAttrList(sNode,subAtrKeyword));
}
return subAttrList;
}
Returns
The xml keyword value or an empty String if the attribute is empty.

◆ name

String Attribute::name ( )
slot

The name of the Attribute.

This is the name as seen in the Layer Properties or Timeline views. The name of an Attribute is not unique within an attribute set.

This example sets the 3d position of a drawing to the 3d point (5,10,0) using name() while iterating through the list of attributes.

function moveDrawing()
{
var sNode = selection.selectedNode(0);
if (node.type(sNode) == "READ")
{
var myAttr = node.getAttrList(sNode, frame.current(), "");
var position = new Point3d(5,10,0);
for(i=0; i < myAttr.length; i++)
{
if(myAttr[i].name() == "Position")
{
myAttr[i].setValue(position);
}
}
}
}
Returns
The name of the Attribute.

◆ pos2dValue

virtual Point2d Attribute::pos2dValue ( )
virtualslot

Fetches the Point2d value from the Attribute at the current frame.

This example prints just the Point2d values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "POSITION_2D")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
MessageLog.trace(wAttr.pos2dValue(frame.current()));
}
}
}
Returns
The Point2d value, or (0,0) if it cannot be cast to a Point2d object.

◆ pos2dValueAt

virtual Point2d Attribute::pos2dValueAt ( double  frame)
virtualslot

Fetches the Point2d value from the Attribute at the specified frame.

This example prints just the Point2d values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "POSITION_2D")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
//frame.current() is used here making it functionally identical to wAttr.pos2dValue()
MessageLog.trace(wAttr.pos2dValueAt(frame.current()));
}
}
}
Parameters
frame: The frame number.
Returns
The Point2d value, or (0,0) if cannot be cast to a Point2d object.

◆ pos3dValue

virtual Point3d Attribute::pos3dValue ( )
virtualslot

Fetches the Point3d value from Attribute at current frame.

This example prints just the Point3d values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "POSITION_3D")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
MessageLog.trace(wAttr.pos3dValueAt(frame.current()));
}
}
}
Returns
The Point3d value, or (0,0,0) if it cannot be cast to a Point3d object.

◆ pos3dValueAt

virtual Point3d Attribute::pos3dValueAt ( double  frame)
virtualslot

Fetches the Point3d value from the Attribute at the specified frame.

This example prints just the Point3d values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "POSITION_3D")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
//frame.current() is used here making it functionally identical to wAttr.pos3dValue()
MessageLog.trace(wAttr.pos3dValueAt(frame.current()));
}
}
}
Parameters
frame: The frame number.
Returns
The Point3d value, or (0,0,0) if cannot be cast to a Point3d object.

◆ setValue [1/5]

virtual void Attribute::setValue ( QObject  value)
virtualslot

Sets the value of the Attribute.

This example sets the 3d position of a drawing to the 3d point (5,10,0).

function moveDrawing()
{
var sNode = selection.selectedNode(0);
if (node.type(sNode) == "READ")
{
var myAttr = node.getAttrList(sNode, frame.current(), "");
var position = new Point3d(5,10,0);
for(i=0; i < myAttr.length; i++)
{
if(myAttr[i].name() == "Position")
{
myAttr[i].setValue(position);
}
}
}
}
Parameters
value: The QObject (such as Point3d or ColorRGBA) value to set the Attribute to.

◆ setValue [2/5]

virtual void Attribute::setValue ( int  value)
virtualslot

Sets the value of the Attribute.

This example sets the Pencil Lines Smoothing attribute of a drawing node to 100.

function setPencilLinesSmoothing()
{
var sNode = selection.selectedNode(0);
if (node.type(sNode) == "READ")
{
var myAttr = node.getAttrList(sNode, frame.current(), "");
for(i=0; i < myAttr.length; i++)
{
if(myAttr[i].name() == "Pencil Lines Smoothing" && myAttr[i].typeName() == "INT")
{
myAttr[i].setValue(100);
}
}
}
}
Parameters
value: The integer value to set the Attribute to.

◆ setValue [3/5]

virtual void Attribute::setValue ( double  value)
virtualslot

Sets the value of the Attribute.

This example sets the Skew value of a drawing to 50 via the list of attributes of the selected node. If the selected node is not a drawing node, it does nothing.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function setSkew()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (attrList[j] == "SKEW")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
wAttr.setValue(50);
}
}
}
Parameters
value: The double value to set the Attribute to.

◆ setValue [4/5]

virtual void Attribute::setValue ( bool  value)
virtualslot

Sets the value of the Attribute.

This example flips a drawing horizontally.

function moveDrawing()
{
var sNode = selection.selectedNode(0);
if (node.type(sNode) == "READ")
{
var myAttr = node.getAttrList(sNode, frame.current(), "");
for(i=0; i < myAttr.length; i++)
{
if(myAttr[i].name() == "Flip Horizontal" && myAttr[i].typeName() == "BOOL")
{
myAttr[i].setValue(!myAttr[i].boolValue());
}
}
}
}
Parameters
value: The boolean value to set the Attribute to.

◆ setValue [5/5]

virtual void Attribute::setValue ( String &  value)
virtualslot

Sets the value of the Attribute.

This example changes the Palette Name attribute of a node. The composite node has this attribute.

function setLocalName(newName)
{
var sNode = selection.selectedNode(0);
var myAttr = node.getAttrList(sNode, frame.current(), "");
for(i=0; i < myAttr.length; i++)
{
if(myAttr[i].name() == "Palette Name" && myAttr[i].typeName() == "STRING")
{
myAttr[i].setValue(newName);
}
}
}
Parameters
value: The String value to set the Attribute to.

◆ setValueAt [1/5]

virtual void Attribute::setValueAt ( QObject  value,
double  frame 
)
virtualslot

◆ setValueAt [2/5]

virtual void Attribute::setValueAt ( int  value,
double  frame 
)
virtualslot

◆ setValueAt [3/5]

virtual void Attribute::setValueAt ( double  value,
double  frame 
)
virtualslot

◆ setValueAt [4/5]

virtual void Attribute::setValueAt ( bool  value,
double  frame 
)
virtualslot

◆ setValueAt [5/5]

virtual void Attribute::setValueAt ( String &  value,
double  frame 
)
virtualslot

◆ textValue

virtual String Attribute::textValue ( )
virtualslot

Fetches the String value from the Attribute at the current frame.

This example prints just the string values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "STRING")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
MessageLog.trace(wAttr.textValue());
}
}
}
Returns
The String value, or an empty String if it cannot be cast to a String.

◆ textValueAt

virtual String Attribute::textValueAt ( double  frame)
virtualslot

Fetches the String value from the Attribute at the specified frame.

This example prints just the string values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function printValue()
{
MessageLog.trace("Please select only one node");
return;
}
var attrList = getFlatAttrList(sNode);
var sNode = selection.selectedNode(0);
MessageLog.trace("Node name: \"" +sNode+"\"");
for(var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.typeName() == "STRING")
{
MessageLog.trace(" \""+attrList[j] +"\"("+wAttr.typeName()+")");
//frame.current() is used here making it functionally identical to wAttr.textValue()
MessageLog.trace(wAttr.textValueAt(frame.current()));
}
}
}
Parameters
frame: The frame number.
Returns
The String value, or an empty String if it cannot be cast to a String.

◆ typeName

virtual String Attribute::typeName ( )
virtualslot

The typeName value associated with the Attribute type.

This example uses typeName to print just the boolean values from a list of attributes of a selected node.

Note
This example uses the function getFlatAttrList which is shown as an example for keyword().
function copyAttr(node1, node2, attrKeyword)
{
var attrList = getFlatAttrList(node1);
for (var j=0; j<attrList.length; j++)
{
var wAttr = node.getAttr(sNode, 1, attrList[j]);
if (wAttr.keyword() == attrKeyword)
{
node.createDynamicAttr(node2, wAttr.typeName(), wAttr.keyword(), wAttr.name(), true);
}
}
}
Returns
The typeName value associated with the Attribute type or an empty String if the Attribute is empty.