Parameter.Disconnect
 
 
 

Parameter.Disconnect

Introduced

v2.0

Description

Disconnects any Shader or animation connected to the parameter. Animation that can be removed with this method includes FCurves, Expressions and Operators.

C# Syntax

DataSource Parameter.Disconnect();

Scripting Syntax

oDataSource = Parameter.Disconnect();

Return Value

Previously connected DataSource. Note: The returned object is valid if it is a Shader, but not if it is an FCurve.

Examples

1. VBScript Example

'
' This example illustrates how to disconnect a shader from the photon parameter of a material.
'
NewScene , false
set grid = Application.ActiveSceneRoot.AddGeometry( "Cube","MeshSurface" )
set mat = grid.AddMaterial( "Phong" )
set photon = mat.Parameters("Photon")
set shader = photon.Disconnect()

2. VBScript Example

' 
' Demonstration of using Disconnect to remove an FCurve from a Parameter
' 
NewScene , false
set oCube = Application.ActiveSceneRoot.AddGeometry( "Cube", "MeshSurface" )
set oPosXParam = oCube.PosX
dim aValues
aValues = Array( 0.00, 5.00, 1.00, 6.00, 2.00, 7.00, 3.00, 8.00 )
oPosXParam.AddFCurve2( aValues )
set oFCurve = oPosXParam.Source
Application.LogMessage "Expected value at frame 10: " & oFCurve.Eval( 10 )  
' Disconnect the FCurve
set oFCurve = oPosXParam.Disconnect
' You can still evalute the fcurve but it doesn't belong to the parameter
Application.LogMessage "FCurve value at Frame 10:" & oFCurve.Eval( 10 )  
' Prove that the FCurve is gone.
Application.LogMessage "Source driving Parameter value: " & TypeName( oPosXParam.Source ) 
SetValue "PlayControl.Current", 10
Application.LogMessage( "Parameter value with no FCurve: " & oPosXParam.Value ) 
' Expected output
'INFO : Expected value at frame 10: 8
'INFO : FCurve value at Frame 10:8
'INFO : Source driving Parameter value: Nothing
'INFO : Parameter value with no FCurve: 5

3. JScript Example

/*
        Demonstrates deleting an FCurve with Parameter.Disconnect
*/
NewScene( null, false ) ;
var oCube = Application.ActiveSceneRoot.AddGeometry( "Cube", "MeshSurface" ) ;
var oPosXParam = oCube.PosX
aValues = new Array( 0.00, 5.00, 1.00, 6.00, 2.00, 7.00, 3.00, 8.00 ) ;
oPosXParam.AddFCurve2( aValues ) ;
Application.LogMessage( oPosXParam.Source == null ) ;
oPosXParam.Disconnect();
Application.LogMessage( oPosXParam.Source == null ) ;
// Expected results:
//INFO: false
//INFO: true

4. JScript Example

/*
        Demonstration of removing an expression with Parameter.Disconnect
*/
NewScene( null, false ) ;
var oCube = Application.ActiveSceneRoot.AddGeometry( "Cube","MeshSurface" ) ;
var oLocalKine = oCube.Kinematics.Local
var oPosXParam = oLocalKine.PosX
var oPosYParam = oLocalKine.PosY
oPosXParam.AddExpression( oPosYParam.FullName + " * 2.0" ) ;
Application.LogMessage( "Before disconnecting:" ) ;
Application.LogMessage( "Source: " + oPosXParam.Source.Type  ) ;
Application.LogMessage( "Number of Animated parameters: " + oCube.AnimatedParameters().Count ) ;
oPosXParam.Disconnect();
Application.LogMessage( "After disconnecting:" ) ;
Application.LogMessage( "Source is null? " + ( oPosXParam.Source == null ) ) ;
Application.LogMessage( "Number of Animated parameters: " + oCube.AnimatedParameters().Count ) ;
//INFO : Before disconnecting:
//INFO : Source: Expression
//INFO : Number of Animated parameters: 1
//INFO : After disconnecting:
//INFO : Source is null? true
//INFO : Number of Animated parameters: 0

5. JScript Example

/*
        Example of removing an Operator using Parameter.Disconnect
*/
NewScene( null, false );
var obj = Application.ActiveSceneRoot.AddNull();
obj.posx.AddScriptedOp( myexpr_Update.toString(), obj.posy, "myexpr", "JScript" );
// Invoke the custom operator
obj.posy = 26 ;
// posx will have been changed to 20 by the operator
Application.LogMessage( "Value of posx:" + obj.posx.Value ) ;
obj.posx.Disconnect() ;
// Change the value of posy again
// However because there is no operator 
// now it will have no effect on posx
obj.posy = 18 ;
Application.LogMessage( "No source anymore? " + (obj.posx.Source == null) ) ;
Application.LogMessage( "Value of posx " + obj.posx.Value ) ;
//Expected output:
//INFO : Value of posx:20
//INFO : No source anymore? true
//INFO : Value of posx 20
function myexpr_Update( ctx, out, inposy )
{
        var posYVal = inposy.Value ;
        if ( posYVal < 20 )  
                out.Value = inposy;
        else
                out.Value = 20 ;        
}

See Also

RemoveAnimation Parameter.Source Parameter.Connect Parameter.ConnectFromFile Parameter.ConnectFromPreset Parameter.ConnectFromProgID