| Author |
Message |
Rogerio_Brazil
Guest
|
Posted:
Fri Jan 07, 2005 8:13 pm Post subject:
how to extract coordinates of a pline and named? |
|
|
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 :)
|
|
| Back to top |
|
 |
Rogerio_Brazil
Guest
|
Posted:
Fri Jan 07, 2005 8:45 pm Post subject:
Re: how to extract coordinates of a pline and named? |
|
|
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 |
|
| Back to top |
|
 |
wkiernan
Guest
|
Posted:
Fri Jan 07, 2005 9:11 pm Post subject:
Re: how to extract coordinates of a pline and named? |
|
|
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.
|
|
| Back to top |
|
 |
Rogerio_Brazil
Guest
|
Posted:
Fri Jan 07, 2005 9:24 pm Post subject:
Re: how to extract coordinates of a pline and named? |
|
|
Thank very much!!!
Rogerio :) |
|
| Back to top |
|
 |
|
|
|
|