Type Conversion Expressions

A type conversion expression casts an object from its current type to another type. Scenome Scripting Language uses C-style casting.

Details

Details are as follows:

Examples

The following example gets a selected node and casts any selected <Material> node to type <Material> in order to operate on it as a <Material>.

Node node = Model.GetSelectedNode( 0 ).GetNode();

if( node.IsDerived( Material ) )
{
   Material material = (Material)Model.EditNode( node );

   material.AlphaBlend = !material.AlphaBlend;
   material.Opacity = 0.5;
}

The following example casts a node to type <Group> and then performs another cast that converts the first child of the <Group> to a node of type <Group>.

Group existingPalette = (Group)((Group)parentNode).Children[ 0 ];

The following example casts a node to type <Group> in order to pass it to a function called AddNode.

Node selNode = Model.GetSelectedNode( i ).GetNode();
if( selNode.IsDerived( Group ) )
{
   Program program = new Program;
   program.Name = "NewProgramNode";

   AddNode( program, (Group)selNode );
}