how to extract coordinates of a pline and named?

Discussion in 'AutoCAD' started by Rogerio_Brazil, Jan 7, 2005.

  1. First, sorry my english.

    Please, how to extract coordinates of a pline?

    The routine GPP get the points list of pline, but (if a 4 vertices pline) how to get a first, 2nd, 3rd or 4th coordinates and named it to P1, P2, P3 and P4?

    !P1 (-159.552 152.485)
    !P2 (-124.387 202.1)
    !P3 (-86.1201 164.889)
    !P4 (-46.8188 202.1)

    NTH function? - how to use?

    The vertices number as stored an QTD-VERT.

    The list of coordinates in VLIST.

    and....

    how to get

    (-159.552 152.485) (-124.387 202.1) (-86.1201 164.889) (-46.8188 202.1)

    from

    ((-159.552 152.485) (-124.387 202.1) (-86.1201 164.889) (-46.8188 202.1) ) ??

    See the routine:

    (defun C:GPP ()(C:pLINEPOINTLIST));;Get Pline Points
    (defun C:pLINEPOINTLIST ()
    (setq mypline (car(entsel "Select LWPline"));pick your lwpline
    vlist (lwcoord mypline);get the vertices as a 2d list
    )
    (setq DADOS (entget mypline));;pline data
    (setq QTD-VER (cdr (assoc 90 DADOS)));;vertices qtd.
    ;;;;(setq PT_FIM (cdr (nth .....;;NTH function to get a vertices coordinates and called as P1, P2,P3 and P4
    (princ "\n ")
    (princ VLIST);;points list
    (princ))

    Thanks in advance,

    Rogério :)
     
    Rogerio_Brazil, Jan 7, 2005
    #1
  2. Sorry. A routine:

    (defun C:GPP ()(C:pLINEPOINTLIST));;Get Pline Points
    (defun c:pLINEPOINTLIST ()
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun xyList->ListOfPoints (coordList / ptlist)
    (while coordList
    (setq ptlist (append ptlist
    (list (list (car coordList) (cadr coordList)))
    ) ;_ end of append
    coordList (cddr coordList)
    ) ;_ end of setq
    ) ;_ end of while
    ptlist
    ) ;_ end of defun
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun lwcoord (entity / len n e1)
    (setq vertexlist nil)
    (setq e (entget entity)) ;get the entity list
    (setq len (length e)) ;get the length of the list
    (setq n 0) ;set counter to zero
    (repeat len ;repeat for the length of the entity list
    (setq e1 (car (nth n e))) ;get each item in the entity list
    ;and strip the entity code number
    (if (= e1 10) ;check for code 10 (vertex)
    (progn
    (setq vertexlist (append vertexlist (cdr (nth n e))))
    ) ;end progn
    ) ;end if
    (setq n (1+ n)) ;increment the counter
    ) ;end repeat
    (setq vertexlist (xyList->ListOfPoints vertexlist))
    vertexlist
    ) ;end defun
    (vl-load-com);;carrega as funções VL
    (setq mypline (car(entsel "Select LWPline"));pick your lwpline
    vlist (lwcoord mypline);get the vertices as a 2d list
    )
    (setq DADOS (entget mypline));;pline data
    (setq QTD-VER (cdr (assoc 90 DADOS)));;vértices number
    ;;;;(setq PT_FIM (cdr (nth (+ POSI-INI 4 )DADOS))))
    ;; NTH function to extract vertices based in (QTD-VER) ?
    (princ "\n ")
    (princ VLIST);;points list
    (princ))

    Thanks,

    Rogerio
     
    Rogerio_Brazil, Jan 7, 2005
    #2
  3. Rogerio_Brazil

    wkiernan Guest

    If VLIST is

    ((-159.552 152.485) (-124.387 202.1) (-86.1201 164.889) (-46.8188 202.1) )

    then

    (nth 0 VLIST) returns (-159.552 152.485) ,
    (nth 1 VLIST) returns (-124.387 202.1),
    (nth 2 VLIST) returns (-86.1201 164.889),
    (nth 3 VLIST) returns (-46.8188 202.1),
    and (nth 4 VLIST) returns nil.
     
    wkiernan, Jan 7, 2005
    #3
  4. Thank very much!!!

    Rogerio :)
     
    Rogerio_Brazil, Jan 7, 2005
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.