Remember 3December
Find out where to celebrate your 3D CG art...
  • 1/3
You are here:Forum Home / Autodesk® Softimage® / XSI SDK / AddNurbsSurfaceMesh2 and JScript
  RSS 2.0 ATOM  

AddNurbsSurfaceMesh2 and JScript
Rate this thread
 
35845
 
Subscribe to this thread
avatar
  • Location: St. Thomas, Ontario
  • Total Posts: 69
  • Joined: 2008-02-24 20:45:47

Is it possible to create a mesh surface using AddNurbsSurfaceMesh2 in JScript.

I tried this code and the only thing I get is a “syntax error” at the last line.

// ------------------------------------------------------------------
// Test AddNurbsSurfaceMesh2
// ------------------------------------------------------------------ 

var oRoot Application.ActiveProject.ActiveScene.Root ;
var 
2/;

// Create array of control points in the format X,Y,Z,W,V,U with U rows and V colums

var aCv = new Array (

-22,  2100,
-
a2,  2101,
 
a2,  2102,
 
22,  2103,
-
20,  a110,
-
a0,  a111,
 
a0,  a112,
 
20,  a113,
-
20, -a120,
-
a0, -a121,
 
a0, -a122,
 
20, -a123,
-
21, -2130,
-
a1, -2131,
 
a1, -2132,
 
21, -21,  33 ) ;  


var 
ukv = new Array( 1.02.03.04.05.06.0 ) ;
var 
vkv = new Array( 1.02.03.04.05.06.0 ) ;


// Create nurbs surface from default values
// Count,ControlPoint,NbUControlPoints,NbVControlPoints,UKnots,NbUKnots,VKnots,NbVKnots,
// UDegree,VDegree,UClosed,VClosed,UParam,VParam,NurbsFormat,Name

var ns oRoot.AddNurbsSurfaceMesh2(1,aCv,,,ukv,,vkv,,,,,,,,siSINurbs,"MyDefaultNurbsSurface";


Replies: 0
avatar
  • mantom
  • Posted: 22 October 2009 02:33 PM
  • Total Posts: 110
  • Joined: 2008-02-20 08:42:03

You need to make some changes to make this work:

First, you can’t pass an empty argument to a command in Jscript, you have to use an equivalent value depending on the parameter type.  Usually it’s the null keyword (null), but sometimes it may be an empty string ("") or the number zero (0).

example:

VBscript:
   
SomeFunction( , , , somevalue )

JScript
:
   
SomeFunction( nullnullnullsomevalue )

If the argument expects an array, then you must pass an array.  null won’t work in those cases.

Second, this command takes arrays as input for most of it’s arguments.  You’ll need to create a separate array for each argument and populate it with a value for each curve in U and V.  Think of this command as a ‘for’ loop which calls it’s cousin AddNurbsSurfaceMesh() iteratively.  Each time through the loop it pulls the n’th value in each array argument and uses those as the argument values.

Third, saw your post on XSIBase.com.  JScript arrays are always flattened to 1-dimensional arrays by XSI.  VBSafeArrays are read-only from JScript, but can be converted to JScript arrays using the .toArray() method

// XSI command returns an array as a VB Safe Array
var aVBSafeArray SomeXSIFunctionWhichReturnsAnArray()

// Convert the safe array to a JScript array.
// result is a 1-dimension JScript array
var aItems ( aVBSafeArray ).toArray()


Replies: 0
avatar
  • Location: St. Thomas, Ontario
  • Total Posts: 69
  • Joined: 2008-02-24 20:45:47

Thank you mantom for your quick reply. I was under the weather for the past week and was only able to reply to your comments today.

Thank you for the reminder about converting VBScript ,,,, to JScript ,null,null,null ...I knew about it as I did change some scripts before but I feel red in the face. I guess I’ll remember it this time! I guess every novice programmers goes through that more than once.

As for your comment about the AddNurbsSurfaceMesh2 accepting arrays, I did try to load the null and “” to confirm your statement and yes, the commands only accept arrays. So I modified the program in the explicit form to pass arrays to AddNurbsSurfaceMesh2.

The only result I got was crashing Softimage.

So, I guess their is more digging to do on that problem.

Thanks for your help and tips! Cheers!

Dan



Replies: 0




   
  Settings Choose Theme color: