Autodesk 15606-011408-9300 Developer Guide - Page 60
and the following statements are processed, The first statement uses - 0 60 6 seconds
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 60 highlights
Otherwise, the function creates some more variables. The obj variable contains the first (and only) object in the current selection. The vertices and cntVertices variables hold empty MGCollection objects: var obj = sel.getMapObjectsEx(layer).item(0); var vertices = map.createObject("MGCollection"); var cntVertices = map.createObject("MGCollection"); Then doGetCoordinates uses the getVertices method to get the coordinates and number of vertices of obj, our selected parcel feature. The values getVertices obtains are passed to the empty vertices and cntVertices collections. If getVertices is successful, it returns an integer telling the number of vertices it found; otherwise, it returns zero. The getVertices return value is passed to a variable called res. If getVertices returns zero, an alert displays and the function terminates: var res = obj.getVertices(vertices, cntVertices); if (res == 0) { alert("No access to coordinate information."); return; } Next, doGetCoordinates uses a for loop to cycle through the vertices collection, placing all of the coordinate listings in a single msg variable: msg = "Parcel:" + obj.getKey() + "\n"; msg = msg + "Coordinates in MCS unit\n"; for(var i = 0; i < cntVertices.item(0); i++) { var pnt = vertices.item(i); msg = msg + pnt.getX() + "," + pnt.getY() + "\n"; } The cntVertices variable tells the for loop to iterate once for each vertex in the object. At each iteration, the loop counter variable (i) is incremented and the following statements are processed: var pnt = vertices.item(i); msg = msg + pnt.getX() + "," + pnt.getY() + "\n"; The first statement uses the item method to select a vertex from the collection and assign it to a variable called pnt. The second statement operates on the pnt variable, using the getX and getY methods to get the vertex coordinates and assign them to msg. As with the previous examples, a new line is added to msg each time the for loop iterates. After all coordinates have been added to msg, the contents of the variable are displayed in a JavaScript alert box: alert(msg); 60 | Chapter 4 Working with Map Layers, Map Features, and Printing