FCurve.BeginEdit

導入

v3.0

詳細

F カーブに対して実行する一括編集の記録を開始します。BeginEdit の呼び出しは、変更をアンドゥ/リドゥスタックに格納するFCurve.EndEditの呼び出しと組み合わせる必要があります。

編集による変更は、FCurve.UndoEditの呼び出しにより元に戻すことができます。また、F カーブが一括編集中かどうかを確認するには、FCurve.IsEditingメソッドを使用します。

注:別の一括編集を開始しようとすると警告が表示され、現在の編集はアンドゥ/リドゥスタックに格納されます。

スクリプト 構文

FCurve.BeginEdit();

JScript の例

/*
        This JScript example illustrates how to use the editing recording feature
        of fcurves. This allows changes to be committed only after all edits have 
        been completed and undone if necessary.
*/
// Create a null
Application.NewScene( null, false );
var nullobj = ActiveSceneRoot.AddNull();
// Create an fcurve on the posx parameter from the null
var fc = nullobj.posx.AddFCurve();
// Define a random number of keys
var nbkeys = Math.round( Math.random() * 100 );
LogMessage( nbkeys );
var arraysize = nbkeys * 2;
var keys = new Array( 2 * nbkeys );
var i = 0, empty;
var offset = -50;
for ( i=0; i<arraysize; i+=2 )
{
        keys[i] = offset + i;
        keys[i+1] = (Math.cos( (i + 1) / 10 ) * 50);
}
// Set the keys on the fcurve
fc.SetKeys(keys);
// Begin recording changes to fcurve
fc.BeginEdit();
if ( fc.IsEditing() )
{
        LogMessage( "fcurve is recording changes" );
}
// Assign random values to keys
for ( i=0; i<fc.GetNumKeys(); i++ )
{
        // Assign a randon value to keys
        fc.Keys(i).Value = ( Math.random() * 100 ) - 50;
}
// If the number of keys if greater than 50 then undo all the 
// changes you just made
var nbkeys = fc.GetNumKeys();
if ( nbkeys > 50 )
{
        LogMessage( "undoing changes" );
        fc.UndoEdit();
}
nbkeys = fc.GetNumKeys();
LogMessage( "total number of keys = " + nbkeys );
// End editing (not necessary to call if changes were undone)
fc.EndEdit();
if ( !fc.IsEditing() )
{
        LogMessage( "fcurve has finished recording changes" );
}
// Outputs:
//INFO : 46
//INFO : fcurve is recording changes
//INFO : total number of keys = 46
//INFO : fcurve has finished recording changes

関連項目

FCurve.EndEdit FCurve.UndoEdit FCurve.IsEditing