Coordinate Property (ActiveX)

Specifies the coordinate of a single vertex in the object.

Supported platforms: Windows only

Signature

VBA:

object.Coordinate(index)
object

Type: 3DFace, 3DPoly, Leader, LWPolyline, PolyfaceMesh, PolygonMesh, Polyline, Section, Solid, SubDMesh, Trace

The objects this property applies to.

index

Type: Integer

The index in the array of vertices for the vertex you want to set or query. The vertex arrays are 0 based.

Property Value

Read-only: No

Type: Variant (three-element or two-element array of doubles)

The array of X, Y, and Z coordinates for the specified vertex.

LightweightPolyline object: The variant has two elements representing the X and Y coordinates in OCS.

Polyline object: The variant has three elements, representing the X and Y coordinates in OCS. The Z coordinate is present in the variant but ignored.

All other objects: The variant has three elements, representing the X and Y coordinates in WCS; the Z coordinate will default to 0 on the active UCS.

Remarks

This property will replace any existing vertices for the specified object. Use standard array-handling techniques to process the values contained in this property.

3DPolyline, Polyline, 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.

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_Coordinate()
    ' This example creates a polyline in model space and
    ' queries and changes the coordinate in the first index position.
        
    Dim plineObj As AcadPolyline
    Dim points(0 To 14) As Double
    
    ' Define the 2D polyline points
    points(0) = 1: points(1) = 1: points(2) = 0
    points(3) = 1: points(4) = 2: points(5) = 0
    points(6) = 2: points(7) = 2: points(8) = 0
    points(9) = 3: points(10) = 2: points(11) = 0
    points(12) = 4: points(13) = 4: points(14) = 0
        
    ' Create a lightweight Polyline object in model space
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
    ZoomAll
    
    ' Find the coordinate in the first index position
    Dim coord As Variant
    coord = plineObj.Coordinate(0)
    MsgBox "The coordinate in the first index position of the polyline is: " & coord(0) & ", " _
        & coord(1) & ", " & coord(2)
    
    ' Change the coordinate
    coord(0) = coord(0) + 1
    plineObj.Coordinate(0) = coord
    plineObj.Update
    
    ' Query the new coordinate
    coord = plineObj.Coordinate(0)
    MsgBox "The coordinate in the first index position of the polyline is now: " & coord(0) & ", " _
        & coord(1) & ", " & coord(2)
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Coordinate()
    ;; This example creates a polyline in model space and
    ;; queries and changes the coordinate in the first index position.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
     
    ;; Define the 2D polyline points
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 14)))
    (vlax-safearray-fill points '(1 1 0
				  1 2 0
				  2 2 0
				  3 2 0
				  4 4 0
				 )
    )
        
    ;; Create a lightweight Polyline object in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq plineObj (vla-AddPolyline modelSpace points))
    (vla-ZoomAll acadObj)
    
    ;; Find the coordinate in the first index position
    (setq coord (vlax-safearray->list (vlax-variant-value (vla-get-Coordinate plineObj 0))))
    (alert (strcat "The coordinate in the first index position of the polyline is: "
		   (rtos (nth 0 coord) 2) ", " (rtos (nth 1 coord) 2) ", " (rtos (nth 2 coord) 2)))
    
    ;; Change the coordinate
    (setq newCoord (vlax-make-safearray vlax-vbDouble '(0 . 2)))
    (vlax-safearray-fill newCoord (list (+ (nth 0 coord) 1)
				        (nth 1 coord)
				        (nth 2 coord)))

    (vla-put-Coordinate plineObj 0 newCoord)
    (vla-Update plineObj)
    
    ; Query the new coordinate
    (setq coord (vlax-safearray->list (vlax-variant-value (vla-get-Coordinate plineObj 0))))
    (alert (strcat "The coordinate in the first index position of the polyline is now: "
		   (rtos (nth 0 coord) 2) ", " (rtos (nth 1 coord) 2) ", " (rtos (nth 2 coord) 2)))
)