## Source.AddProperty

### Introduced

v4.0

### Description

Creates and adds a UserDataBlob or CustomProperty to a Source object.

### C# Syntax

    Property Source.AddProperty( Object in_Preset, Boolean in_Branch, String in_name );

### Scripting Syntax

    oReturn = Source.AddProperty( Preset, [BranchFlag], [Name] );

### Return Value

CustomProperty, UserDataBlob or UserDataMap, depending on the preset that was used.

### Parameters

Parameter | Type | Description
--- | --- | ---
Preset | String | This argument contains either the name of a Property Preset or a string with the filename or full path to a Preset file. Note: Only CustomProperty Presets, UserDataBlob Presets, and UserDataMap Presets are valid for sources. The type of property that is created is determined by this argument. For example, "CustomProperty" creates an empty CustomProperty and "UserDataBlob" creates a UserDataBlob.
BranchFlag | Boolean | False is the only supported value Default Value: false
Name | String | Represents the name of the new property (see SIObject.Name). If not specified the object is named based on the Preset argument.

### Examples

#### JScript Example

    /*
            This example shows how to add user data to a shape source
    */
    // First build a simple scene
    NewScene( null, false );
    var oCone = ActiveSceneRoot.AddGeometry( "Cone", "MeshSurface" );
    // Set up the time in seconds
    var oPlayCtrl = GetValue("PlayControl");
    var dFrameRate = oPlayCtrl.Parameters("Rate").Value;
    var dTime = 1.0 * dFrameRate;                                   // start at the beginning
    // Using SaveShapeKey stores the source and applies the clip simultaneously
    var aIndices = new Array( 1,4,7,10,13,16,19,22,25 );
    var aPositions = new Array( /*    X,        Y,        Z         */
                                    0,        1.6667,  0,           // point 1
                                    -0.5,     -0.5,    0,           // point 4
                                    -0.3536,  -0.5,    -0.3536,     // point 7
                                    0,        -0.5,    0.5,         // point 10
                                    0.3536,   -0.5,    0.3536,      // point 13
                                    0.5,      -0.5,    0,           // point 16
                                    0.3536,   -0.5,    -0.3536,     // point 19
                                    0,        -0.5,    -0.5,        // point 22
                                    -0.3536,  -0.5,    -0.3536      // point 25
                            );
    var oShapeClip = oCone.ActivePrimitive.Geometry.SaveShapeKey(
                            dTime,                                  // Time (when to evaluate)
                            -1,                                     // ClipDuration
                            siShapeObjectReferenceMode,             // RefMode (shape ref. mode)
                            siShapeMixedWeightMode,                 // InstMode (shape inst. mode)
                            "MyNewShape",                           // Name for shape
                            aIndices,                               // IndexArray (point indices)
                            aPositions                              // PositionArray (key positions)
                    );
    // Add a CustomProperty nested under the Source of the 1st clip
    var oShapeSource = oShapeClip.Source;
    var oShapePSet = oShapeSource.AddProperty( "CustomProperty",false, "ShapePSet" );
    oShapePSet.AddParameter3( "Foo", siString ) ;
    // Add a UserDataBlob nested under the ShapeSource
    var oShapeUserDataBlob = oShapeSource.AddProperty( "UserDataBlob" );
    LogMessage( "There are " + oShapeSource.Properties.Count + " Properties under this Shape Source" ) ;
    // Expected result:
    //INFO : There are 2 Properties under this Shape Source

### See Also

SceneItem.AddProperty Source.Properties