Ok, try this:
Code:
(defun c:plco (/ File oFile pLin pStr pEnt nlist pLen wLine wfLine vPt wvLine)
(if (setq File (getfiled "Create a Text File" "C:\\" "txt" 9))
(progn
(setq oFile (open file "W"))
(while (setq pLin (ssget ":S" (list (cons 0 "LWPOLYLINE,POLYLINE") (cons 410 (getvar "CTAB")))))
(sssetfirst nil pLin)
(if (/= (setq pStr (getstring t "\nSpecify Name for Selected Polyline >> ")) "")
(progn
(setq pEnt (ssname pLin 0))
(cond ((= "LWPOLYLINE" (cdr (assoc 0 (entget pEnt))))
(foreach x (entget pEnt)
(if (eq 10 (car x))
(setq nlist (cons (cdr x) nlist))
) ;_ end if
) ;_ end foreach
(setq nlist (reverse nlist)
pLen (length nlist)
wfLine ""
) ;_ end setq
(while (not (minusp (setq pLen (1- pLen))))
(setq wLine (strcat (rtos (car (nth pLen nlist)) 2 2)
","
(rtos (cadr (nth pLen nlist)) 2 2)
) ;_ end strcat
) ;_ end setq
(setq wfLine (strcat wLine "\t" wfLine))
) ;_ end while
(write-line (strcat pStr "\t" wfLine) oFile)
)
((= "POLYLINE" (cdr (assoc 0 (entget pEnt))))
(setq wvLine ""
pEnt (entnext pEnt)
) ;_ end setq
(while (/= (cdr (assoc 0 (entget pEnt))) "SEQEND")
(setq vPt (cdr (assoc 10 (entget pEnt)))
wvLine (strcat (rtos (car vPt) 2 2)
","
(rtos (cadr vPt) 2 2)
","
(rtos (caddr vPt) 2 2)
"\t"
wvLine
) ;_ end strcat
pEnt (entnext pEnt)
) ;_ end setq
) ;_ end while
(write-line (strcat pStr "\t" wvLine) oFile)
)
) ;_ end cond
) ;_ end progn
(princ "\n<!> No Line Name Specified. <!>")
) ;_ end if
(sssetfirst nil)
) ;_ end while
(close oFile)
) ;_ end progn
(princ "\n<!> No File Selected. <!> ")
) ;_ end if
(princ)
) ;_ end defun
Bookmarks