Re: [script] Creating relative values fcurve

Date : Mon, 30 Apr 2007 13:12:38 -0400
To : XSI(at)Softimage.COM
From : "Bernard Lebel" <3dbernard(at)gmail.com>
Subject : Re: [script] Creating relative values fcurve
Your script works perfectly, Kim. For "typlical" fcurves (that is, on transformations) I never had a problem creating those by script. But now I'm trying to create the fcurve of a link with _expression_ that connects the shapes (in the mixer) with cpset parameters.


Below is a script that re-produces my problem. The first part does like when I create the relative values manually. The second parts uses the SetKeys() method. The third one is the for loop we've been trying.

With second and last approach I'm getting exactly the same results. The first keyframe is 0/0, and the second one is 0.24/6.


Cheers
Bernard




NewScene( null, false );

// Create primitives
var oSphere = activesceneroot.addgeometry( "Sphere", "MeshSurface" );
var >


var oSphereParam = oSphere.kinematics.local.posy;
var >

var aParams = new Array( oSphereParam.fullname, oNullParam.fullname );
var sParams = aParams.join( "," );


var sExpression = "l_fcv( ".concat(oNullParam.fullname, " )")

// Create the link with _expression_
oSphereParam.addexpression( sExpression );

SetRelativeValues( oSphereParam.fullname );

// Move the null and sphere away, set a new relative value
oSphereParam.value = 6;
oNullParam.value = 6;

SetRelativeValues( oSphereParam.fullname );



/////////////////////////////////////////////////////////////



// Remove _expression_
oSphereParam.disconnect();

// Recreate the _expression_
oExpression = oSphereParam.addexpression( sExpression );

var aFcurveKeys = new Array( 0, 0, 6, 6 );

// Get the _expression_ object
var oExpression = oSphereParam.source;

// Get the _expression_ fcurve for relative value
var oFcurveParam = oExpression.nestedobjects( "l_fcv" );
var oFcurve = oFcurveParam.source;

// DOESN'T RESULT IN PROPER FCURVE -> [0, 0, 0.24, 6]
oFcurve.setkeys( aFcurveKeys );




/////////////////////////////////////////////////////////////



// Remove keys
oFcurve.removekeys( 1, 100, true );


// Create keyframes via a for loop

oFcurve.beginedit();

iLength = aFcurveKeys.length;

var fTime, fValue;
for( var i = 0; i < iLength; i=i+2 )
{
    fTime = aFcurveKeys[i];
    fValue = aFcurveKeys[i+1];
    oFcurve.addkey( fTime, fValue, 0, true );
}

oFcurve.endedit();

// DOESN'T RESULT IN PROPER FCURVE -> [0, 0, 0.24, 6]








On 4/30/07, kim aldis <kim.aldis(at)gmail.com> wrote:
> Just for the pure pendency of it Bernard, try just cutting the script out of
> my  mail and pasting from one of these mails into a new xsi at your end, see
> what happens. You never know.

Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.