1. Help about coordinate of polyline

Registered forum members do not see this ad.

Hi,
How can I get coordinate of each vertex of polyline? I use VBA in autocad2004.
Thank you !

2. Will LIST help? Do a LIST of the polyline, that will return all the vertex coords.

One appears to have an answer -

4. Code:
```(defun get-coord (/ ent res loc:conv-list-to-3d)

(defun loc:conv-list-to-3d (lst)
(cond
((not lst) nil)
(t
(loc:conv-list-to-3d (cdddr lst))
) ;_ end of cons
)
) ;_ end of cond
) ;_ end of defun

(if (and (= (type (setq ent
(vl-catch-all-apply
'(lambda () (car (entsel "\nSelect a polyline <Cancel> : ")))
) ;_ end of vl-catch-all-apply
) ;_ end of setq
) ;_ end of type
'ename
) ;_ end of =
(wcmatch (cdr (assoc 0 (entget ent))) "*POLYLINE")
) ;_ end of and
(setq
res (cond
((= (cdr (assoc 0 (entget ent))) "LWPOLYLINE")
(mapcar
'(lambda (x) (trans (cdr x) (cdr (assoc 210 (entget ent))) 0))
(vl-remove-if-not '(lambda (a) (= (car a) 10)) (entget ent))
) ;_ end of mapcar
)
((= (cdr (assoc 0 (entget ent))) "POLYLINE")
(loc:conv-list-to-3d
(vlax-safearray->list
(vlax-variant-value
(vla-get-coordinates (vlax-ename->vla-object ent))
) ;_ end of vlax-variant-value
) ;_ end of vlax-safearray->list
) ;_ end of loc:conv-list-to-3d
)
) ;_ end of cond
) ;_ end of cond
) ;_ end of if
res
) ;_ end of defun```

5. Registered forum members do not see this ad.

try this.
Public sub GetPLCoords
Dim intVCnt As Integer
Dim varCords As Variant
Dim varCord As Variant
Dim varNext As Variant
Dim intCrdCnt As Integer
Dim intDiv As Integer
ThisDrawing.Utility.GetEntity objGen, varPnt,
varCords = objPline.Coordinates
intVCnt = 0
For Each varVert In varCords
intVCnt = intVCnt + 1
Next
intDiv = 3
ProObjCount = intVCnt / intDiv - 1
ReDim MyProfileObj(0 To ProObjCount)
For intCrdCnt = 0 To ProObjCount
If intCrdCnt < intVCnt / intDiv - 1 Then
varCord = objPline.Coordinate(intCrdCnt)
varNext = objPline.Coordinate(intCrdCnt + 1)
ElseIf objPline.Closed Then
varCord = objPline.Coordinate(intCrdCnt)
varNext = objPline.Coordinate(0)
Else
Exit For
End If
Exit sub

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts