Re: Curve creation using geometry.set

Date : Wed, 2 Apr 2008 17:47:50 -0400
To : xsi <XSI(at)Softimage.COM>
From : "David Barosin" <dbarosin(at)gmail.com>
Subject : Re: Curve creation using geometry.set
Ok I think I got it ;)

Seems that the VBarray is a fixed length per dimension.  So if the first curve has 25 knots and the second has 15 knots the VBArray makes a 2 dimensional array with a fixed length based on the longest dimension which in this case is 25 so the array length is 50.

On Wed, Apr 2, 2008 at 5:06 PM, David Barosin <dbarosin(at)gmail.com> wrote:
I hope someone can shed light on this.  I'm trying to create curves using the geometry.set method.  To help me understand how this method functions I'm looking at what is returned with the geometry.get2 method in jscript. 

most everything looks fine except the array that returns the 'knot' information.

What I get is extra blank values at the end of the array.  I'm not sure what these values are.  If I leave the knot array as is and generate curves the geometry.set method works fine.  If I strip the blank values off the array I get an 'unexpected error' message.  What I'd eventually like to do is feed in my own controlPoint and knot info to geometry.set but I guess I need to understand what the blank values in the array mean.

Here is a script that demonstrates what I'm talking about.  It shows the knot count for both curves in the text object then displays the knot array with it's length.  If you uncomment the * display knot info ** it will list the knot info per curve. 



/////////////////begin

var oRoot = Application.ActiveProject.ActiveScene.Root;
var oText = oRoot.AddGeometry( "Text", "NurbsCurve" );
oText.text = "b";

var vbArgs = new VBArray(oText.ActivePrimitive.Geometry.Get2( siSINurbs ));
var args = vbArgs.toArray();

// Number of knots per curve
var vbArg7 = new VBArray(args[4]);
var nknots = vbArg7.toArray();
for (i = 0; i < nknots.length; i++)
{
LogMessage("number of knots for curve " + i + ": " + nknots[i] );
}

// Knots
var vbArg2 = new VBArray(args[3]);
var knots = vbArg2.toArray();

/*  display knot info *****************
for ( j=0; j<knots.length; j++)
{
    for (i = 0; i < nknots[j]; i++)
    {
        LogMessage("crv" + j + ": " + "knots" + i + ": " + knots[i]);
    }
}
*/

logmessage("knots = " + knots + "  "  + knots.length);


///////////////// end


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.