Accessing Arrays

Accessing Arrays

simon.dyer
Advocate Advocate
570 Views
1 Reply
Message 1 of 2

Accessing Arrays

simon.dyer
Advocate
Advocate

I am tweaking a JS script and need to access an array, but it keeps failing.

Here is a code snippet:

var points = new Array(50);

points[prf] = adsk.core.ObjectCollection.create();

....

var point = adsk.core.Point3D.create(data[i][0], data[i][1], data[i][2]);
points[prf].add(point);

...

 

Now I want to get the value of Z from a point in that array.

Ive tried 

var z=points[1].z;

  z=points[i][2];

then assuming its a method:

z=points[i].getData(x,y,z);

 

Nothing seems to work for me. 

0 Likes
Accepted solutions (1)
571 Views
1 Reply
Reply (1)
Message 2 of 2

marshaltu
Autodesk
Autodesk
Accepted solution

Hello,

 

I would like to tell you Javascript API has been moved to maintenance mode. Please read Brian's post as below:

 

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/new-functionality-and-javascript-moves-to-...

 

Regarding to your specific issue, the following sample will demo how to access ObjectCollection.

 

//Author-
//Description-

function run(context) {

    "use strict";
    if (adsk.debug === true) {
        /*jslint debug: true*/
        debugger;
        /*jslint debug: false*/
    }
 
    var ui;
    try {
        var app = adsk.core.Application.get();
        ui = app.userInterface;
 
        var points = [];
        points[0] = adsk.core.ObjectCollection.create();
        points[0].add(adsk.core.Point3D.create(0, 0 ,0));
        var z = points[0].item(0).z;
        ui.messageBox("Z: " + z.toString());
    } 
    catch (e) {
        if (ui) {
            ui.messageBox('Failed : ' + (e.description ? e.description : e));
        }
    }

    adsk.terminate(); 
}

Thanks,

Marshal

 



Marshal Tu
Fusion Developer
>
0 Likes