Lee Mac Posted January 28, 2009 Share Posted January 28, 2009 If the notepad file: "Desired" is indeed what you would like: ;| Polyline Coordinate Writer by Lee McDonnell 27.01.2009 |; ; Version 2 ~ Polyline Writing Format Altered. (defun c:plco2 (/ File oFile ss eLst Selss pName aEnt vLst i vNme) (vl-load-com) (if (setq File (getfiled "Create a Text File" "C:\\" "txt" 9)) (progn (setq oFile (open File "W")) (if (setq ss (ssget (list (cons 0 "POLYLINE") (if (getvar "CTAB") (cons 410 (getvar "CTAB"))(cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) Selss (ssadd)) (foreach ent eLst (ssadd ent Selss) (sssetfirst nil Selss) (if (not (setq pName (getstring t "\nSpecify Name for Selected Polyline > "))) (setq pName (vl-princ-to-string ent))) (setq aEnt (entnext ent)) (while (/= "SEQEND" (cdr (assoc 0 (entget aEnt)))) (setq vLst (cons (cdr (assoc 10 (entget aEnt))) vLst) aEnt (entnext aEnt))) (setq i (length vLst)) (while (not (minusp (setq i (1- i)))) (write-line (strcat pName "\t" (rtos (car (nth i vLst)) 2 2) "," (rtos (cadr (nth i vLst)) 2 2) "," (rtos (caddr (nth i vLst)) 2 2) "\n") oFile)) (setq vLst nil) (ssdel ent Selss) (sssetfirst nil nil))) (princ "\n<!> No Polyline Selected <!>"))) (princ "\n<!> No File Selected <!>")) (close oFile) (princ "\n...Vertices Written to File...") (princ)) Then the above should do your bidding. Quote Link to comment Share on other sites More sharing options...
iztok13 Posted January 28, 2009 Author Share Posted January 28, 2009 ok the the desire file is ok, But when i run plco2 lisp writen above i cant select poly, it say nothing selected???? please try the file wich i upload and try if you have the same problem? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 28, 2009 Share Posted January 28, 2009 I can't get to the file you uploaded... Can you not attach the file? Quote Link to comment Share on other sites More sharing options...
iztok13 Posted January 28, 2009 Author Share Posted January 28, 2009 Ok here is the same file; polylines.dwg Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 28, 2009 Share Posted January 28, 2009 Ahh, you are using (2D) LWPolylines - I shall alter the LISP accordingly Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 28, 2009 Share Posted January 28, 2009 Here you are - just window the whole drawing to select polylines (as in your example). ;| Polyline Coordinate Writer by Lee McDonnell 27.01.2009 |; ; Modified for use with LWPOLYLINES (defun c:plco2 (/ File oFile ss eLst Selss pName aEnt vLst i) (vl-load-com) (if (setq File (getfiled "Create a Text File" "C:\\" "txt" 9)) (progn (setq oFile (open File "W")) (if (setq ss (ssget (list (cons 0 "LWPOLYLINE") (if (getvar "CTAB") (cons 410 (getvar "CTAB"))(cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) Selss (ssadd)) (foreach ent eLst (ssadd ent Selss) (sssetfirst nil Selss) (if (not (setq pName (getstring t "\nSpecify Name for Selected Polyline > "))) (setq pName (vl-princ-to-string ent))) (setq vLst (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget ent)))) (setq i (length vLst)) (while (not (minusp (setq i (1- i)))) (write-line (strcat pName "\t" (rtos (car (nth i vLst)) 2 2) "," (rtos (cadr (nth i vLst)) 2 2) "\n") oFile)) (setq vLst nil) (ssdel ent Selss) (sssetfirst nil nil))) (princ "\n<!> No Polyline Selected <!>"))) (princ "\n<!> No File Selected <!>")) (close oFile) (princ "\n...Vertices Written to File...") (princ)) Quote Link to comment Share on other sites More sharing options...
iztok13 Posted January 29, 2009 Author Share Posted January 29, 2009 Ok I tested, This time I think it really works for me. im really glad that you help me. This routin will make my work much easier than time before. Thank you again. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 No Problem - glad we finally got it sorted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.