JScript: can’t get coords

I really wish I could help. I haven’t experimented much with JScript. Could it be that 3DC is returning andquot;Variantsandquot;?

Richard

Howdy

Can’t seem to get coordinates into my script using JScript. andnbsp;For example, the following code should get the camera position. andnbsp;It works in VBScript ok, but here the coordinates are written to the file as andquot;undefinedandquot;. andnbsp;This seems to happen when I try to get point coordinates as well.

Also, the word Nothing, when used in Group.GetPosition(Nothing,x,y,z) crashes the script. andnbsp;Might abandon the Java experiment if I can’t get this going <!– s:-( –><img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":-(" title="Sad" /><!– s:-( –>

George

code follows – action is all after the dec’s of useless vars…

Language = JScript

//’ Purpose: get camera position
function Main(3DCApp)
{

andnbsp; andnbsp;var fso, tf; andnbsp;//set up file for debug info
andnbsp; andnbsp;fso = new ActiveXObject(andquot;Scripting.FileSystemObjectandquot;);
andnbsp; andnbsp;tf = fso.CreateTextFile(andquot;c:\Program Files\3DC\Scripts\aascriptout.txtandquot;, true);
andnbsp; andnbsp;var Scene ;// andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; ‘The current active scene
andnbsp; andnbsp;var SceneRootGroup;// andnbsp; ‘The root Group of the scene
andnbsp; andnbsp;var Group andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;;//’The Group for our object (face)
andnbsp; andnbsp;var Object andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;;// ‘The object we are creating (face)
andnbsp; andnbsp;var Face andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;;// ‘The face we are creating andnbsp; andnbsp;

andnbsp; andnbsp;var CameraGroup andnbsp;;//
andnbsp; andnbsp;var CamX andnbsp;;// ‘CameraPosition
andnbsp; andnbsp;var CamY;//
andnbsp; andnbsp;var CamZ;//

andnbsp; andnbsp;var ActiveObjectCount;//
andnbsp; andnbsp;var BillboardsObject ;//
andnbsp; andnbsp;var BillboardsGroup;//
andnbsp; andnbsp;var NumberOfBillboards;// andnbsp; ‘in the object
andnbsp; andnbsp;var BoardNumber;//
andnbsp; andnbsp;var NumPoints;//
andnbsp; andnbsp;var FacePoints;//
andnbsp; andnbsp;var BillX ;// ‘the position of the point we are working on
andnbsp; andnbsp;var BillY;//
andnbsp; andnbsp;var BillZ;//
andnbsp; andnbsp;var NewX andnbsp;;// ‘rotated position
andnbsp; andnbsp;var NewY;//
andnbsp; andnbsp;var NewZ;//
andnbsp; andnbsp;var PointsArray =new Array();// andnbsp;just the coords of a point

andnbsp; andnbsp;var AlphaZ;//
andnbsp; andnbsp;var BetaZ;//
andnbsp; andnbsp;var ThetaZ;//
andnbsp; andnbsp;var AlphaY;//
andnbsp; andnbsp;var BetaY;//
andnbsp; andnbsp;var ThetaY;//
andnbsp; andnbsp;var FX ;// ‘normal of face
andnbsp; andnbsp;var FY;//
andnbsp; andnbsp;var FZ;//
andnbsp; andnbsp; andnbsp; andnbsp;//’get the scene
andnbsp; andnbsp; andnbsp; andnbsp;Scene = 3DCApp.GetActiveScene();

andnbsp; andnbsp; andnbsp; andnbsp;//’get the root Group
andnbsp; andnbsp; andnbsp; andnbsp;SceneRootGroup = Scene.GetRootGroup();
andnbsp; andnbsp; andnbsp; andnbsp;CameraGroup=Scene.GetGroup(2); andnbsp;
// andnbsp; andnbsp; andnbsp; ‘get the active object count
andnbsp; andnbsp; andnbsp; andnbsp;ActiveObjectCount = Scene.GetActiveObjectCount();

andnbsp; andnbsp;//’only proceed if there is an active object
andnbsp; andnbsp;if (ActiveObjectCount == 0 )
andnbsp; andnbsp; andnbsp; andnbsp;return;
andnbsp; andnbsp;else
andnbsp; andnbsp;{
andnbsp; //get the active object (right now there can only be one)
andnbsp; andnbsp;BillboardsObject = Scene.GetActiveObject(0);
andnbsp; andnbsp;BillboardsGroup=BillboardsObject.GetParentGroup();
andnbsp; andnbsp;//BillboardsObject.Transform(); andnbsp;
andnbsp; andnbsp;//getthe position of the camera
andnbsp; andnbsp;CameraGroup.GetPosition (BillboardsGroup,CamX,CamY,CamZ);
andnbsp; andnbsp;
andnbsp; andnbsp;tf.writeline(andquot;Cam posandquot;+CamX+andquot; andquot;+CamY+andquot; andquot;+CamZ);

andnbsp;
andnbsp;} andnbsp;//if andnbsp;
tf.Close(); andnbsp; //close file for script out
} andnbsp; //sub

]]Also, the word Nothing, when used in Group.GetPosition(Nothing,x,y,z) crashes the script.

Would NULL or null work?

Later…

Simon

I did andnbsp;a seach on the variant idea. andnbsp;Seems a lot of people have the problem and someone from Microsoft tells them JScript can handle variants without problems, in fact it likes them that way. andnbsp;There were no real answers.

So I dunno. andnbsp;Suggests a bug in the script engine with so many denials…

Null won’t work either.

Anyway, I’ll give it a rest for a while. andnbsp;This can waste a recreational programmer’s few moments.

George

You must be logged in to reply in this thread.

4 posts