+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Forum Newbie
    Using
    AutoCAD 2004
    Join Date
    Dec 2007
    Posts
    2

    Default 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. #2
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

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

  3. #3
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    At the bottom of this page are links to similar topics.

    One appears to have an answer -
    http://www.cadtutor.net/forum/showthread.php?t=7823

  4. #4
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    361

    Default

    Code:
    (defun get-coord (/ ent res loc:conv-list-to-3d)
    
      (defun loc:conv-list-to-3d (lst)
        (cond
          ((not lst) nil)
          (t
           (cons (list (car lst) (cadr lst) (caddr lst))
                 (loc:conv-list-to-3d (cdddr lst))
                 ) ;_ end of cons
           )
          ) ;_ end of cond
        ) ;_ end of defun
    
      (vl-load-com)
      (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
    All I say is only my opinion.

  5. #5
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Nov 2007
    Posts
    19

    Default

    Registered forum members do not see this ad.

    try this.
    Public sub GetPLCoords
    Dim ObjGen As AcadObject
    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

Similar Threads

  1. Get coordinate of polyline by VBA
    By quangducnguyen in forum .NET, ObjectARX & VBA
    Replies: 10
    Last Post: 31st Oct 2014, 11:45 pm
  2. Coordinate Systems
    By MantaBase in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 13th Jul 2007, 05:23 am
  3. Replies: 2
    Last Post: 27th Apr 2007, 08:54 am
  4. Coordinate settings ?
    By CZSteve in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 31st Jan 2007, 10:32 pm
  5. Coordinate list
    By Moesian in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 15th Mar 2005, 03:25 pm

Bookmarks

Posting Permissions

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