Points can be transformed from one coordinate system to another using the TRANSFORMCOORDINATES function.
Consider, for example, how the same point has 4 different sets of coordinates depending on the coordinate system (fixture) with which the coordinates are expressed.
After you transform a point between coordinate systems, you might need to access its X- or Y-coordinate separately (for example, trying to display a coordinate of a point in an operator view's Value element, or using it in a reconfiguration operation). This cannot be done directly.
Although TRANSFORMCOORDINATES can take and return a point object, you cannot create a variable of type Point to hold the object for easy retrieval of its coordinates (only variables of type Point array are possible). To extract the coordinates separately, you need to place the point in an array. Once in an array, you can use the SELECT and the ELEMENTAT functions together to extract the X- or Y-coordinate of the point.
You can pass TRANSFORMCOORDINATES a point object and then place its resulting point object in an array. Alternatively, you can pass TRANSFORMCOORDINATES an array containing the point, and it will return the resulting point in a point array.
When you pass TRANSFORMCOORDINATES a point object containing the point to transform (for example, using the POINT function), it returns the transformed point in a point object. To access the individual X- and Y-coordinates of the transformed point, you must then convert the results to a point array and use the SELECT and ELEMENTAT functions.
The individual parameters of the TRANSFORMCOORDINATES function are:
The data type of the output of TRANSFORMCOORDINATES is the same as the data type of its first parameter, the SourceCoordinates parameter. In this case, since SourceCoordinates is a point object, the output of the TRANSFORMCOORDINATES function is a point object, which can then be placed in a point array using the [] operator.
The SELECT function takes an array and an expression, and returns an array after applying the expression to each element of a source array. In this case, Item.X will return the X-coordinate of the point object, so the function outputs the X-coordinate of the point object in an array: [10].
The ELEMENTAT function takes an array and an index, and returns the element at that index. In this case, it returns the numeric value 10.
Since the TRANSFORMCOORDINATES function supports multiple data types, an equivalent approach is to use POINTARRAY to produce a point array containing the coordinates, and pass it to the TRANSFORMCOORDINATES function. This function will then return the transformed coordinates in a point array. You can then use the SELECT and ELEMENTAT functions on this array.
The following example does this and returns the X-coordinate, in the absolute coordinate system, of the top-left corner of a region.
The individual paramters of the TRANSFORMCOORDINATES function are:
Since the output data type of TRANSFORMCOORDINATES is already a point array, the [] operator is not needed to pass the result to the SELECT function.
In this case, the SELECT and ELEMENTAT functions perform the same roles as in the example in the Passing the source point as a point object subsection of this section.