Coordinates Property (ActiveX)

Specifies the coordinates for each vertex in the object.

Supported platforms: Windows only

Signature

VBA:

object.Coordinates
object

Type: 3DFace, 3DPolyline, Leader, LWPolyline, MLine, Point, PolyfaceMesh, PolygonMesh, Polyline, Solid, SubDMesh, SubDMeshVertex, Trace

The objects this property applies to.

Property Value

Read-only: No

Type: Variant (array of doubles)

The array of points.

3DFace object: The variant is an array of three or four 3D points in WCS.

3DPolyline object: The variant is an array of 3D points in WCS.

Leader object: The variant is an array of 3D points in WCS.

LightweightPolyline object: The variant is an array of 2D points in OCS.

Mline object: The variant is an array of 3D points in WCS.

Point object: The variant is an array of a 3D point in WCS.

PolyfaceMesh object: The variant is an array of 3D points in WCS.

PolygonMesh object: The variant is an array of 3D points in WCS.

Polyline object: The variant is an array of 3D points: the X and Y coordinates are in OCS; the Z coordinate is ignored.

Solid object: The variant is an array of three or four 3D points in WCS.

Trace object: The variant is an array of four 3D points in WCS.

All other objects: The variant is an array of 3D points in WCS.

Remarks

This property will update the coordinates for the specified object. Use standard array-handling techniques to process the coordinates contained in this property.

PolyfaceMesh, PolygonMesh, and Trace: You cannot change the number of coordinates in the object by using this property. You can change only the locations of the existing coordinates.

3DPolyline, Polyline, and PolygonMesh: For simple polylines (not splined or curve fit), this property specifies simple vertices. For splined or curve-fit polylines, this property specifies control point vertices.

When setting the coordinates for a polyline, if you supply fewer coordinates than the object currently possesses, the polyline will be truncated. Any fit points applying to the truncated vertices will also be truncated. If you supply more coordinates than the object currently possesses, the extra vertices will be appended to the polyline.

The OCS coordinates for the Polyline and LightweightPolyline objects can be converted to and from other coordinate systems using the TranslateCoordinates method.

Examples

VBA:

Sub Example_Coordinates()
    ' This example creates a polyline. It then uses the Coordinates
    ' property to return all the coordinates  in the polyline. It then
    ' resets one of the vertices using the Coordinates property.
    
    Dim plineObj As AcadPolyline

    ' Create Polyline
    Dim points(5) As Double
    points(0) = 3: points(1) = 7: points(2) = 0
    points(3) = 9: points(4) = 2: points(5) = 0
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
    ThisDrawing.Regen True

    ' Return all the coordinates of the polyline
    Dim retCoord As Variant
    retCoord = plineObj.Coordinates

    ' Display current coordinates for the second vertex
    MsgBox "The current coordinates of the second vertex are: " & points(3) & ", " & points(4) & ", " & points(5), vbInformation, "Coordinates Example"

    ' Modify the coordinate of the second vertex to (5,5,0). Note that in
    ' case of a lightweight Polyline, indices will be different because the points are 2D only.
    points(3) = 5
    points(4) = 5
    points(5) = 0
    plineObj.Coordinates = points

    ' Update display
    ThisDrawing.Regen True

    MsgBox "The new coordinates have been set to " & points(3) & ", " & points(4) & ", " & points(5), vbInformation, "Coordinates Example"
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Coordinates()
    ;; This example creates a polyline. It then uses the Coordinates
    ;; property to return all the coordinates  in the polyline. It then
    ;; resets one of the vertices using the Coordinates property.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))    

    ;; Create Polyline
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 5)))
    (vlax-safearray-fill points '(3 7 0
				  9 2 0
				 )
    )

    (setq modelSpace (vla-get-ModelSpace doc))
    (setq plineObj (vla-AddPolyline modelSpace points))
    (vla-ZoomAll acadObj)

    ;; Return all the coordinates of the polyline
    (setq retCoord (vla-get-Coordinates plineObj))

    ;; Display current coordinates for the second vertex
    (alert (strcat "The current coordinates of the second vertex are: " (rtos (vlax-safearray-get-element points 3) 2) ", "
		                                                        (rtos (vlax-safearray-get-element points 4) 2) ", "
		                                                        (rtos (vlax-safearray-get-element points 5) 2)))

    ;; Modify the coordinate of the second vertex to (5,5,0). Note that in
    ;; case of a lightweight Polyline, indices will be different because the points are 2D only.
    (vlax-safearray-put-element points 3 5)
    (vlax-safearray-put-element points 4 5)
    (vlax-safearray-put-element points 5 0)
    (vla-put-Coordinates plineObj points)

    ;; Update display
    (vla-Regen doc :vlax-true)

    (alert (strcat "The new coordinates have been set to: " (rtos (vlax-safearray-get-element points 3) 2) ", "
		                                            (rtos (vlax-safearray-get-element points 4) 2) ", "
		                                            (rtos (vlax-safearray-get-element points 5) 2)))
)