Ramana Posted August 16, 2010 Posted August 16, 2010 Dear friends, Greetings I need a help to extract the coordinates of the polyline. I have some rectangles and squares. i would like to extract the 4 vertices coordinates to .txt file. I found that entget is giving coordinates of all vertices of rectangle but the dxf code 10 is same for all vertices, how to extract them independently. Please help me with which function i can get the vertices where i can send them to txt file with file handling function. regards Ramana Quote
Tharwat Posted August 16, 2010 Posted August 16, 2010 Here is one by Mr. Kerry it's really great. http://www.cadtutor.net/forum/showthread.php?51266-4-dxf-codes-for-10 Regards, Tharwat Quote
lpseifert Posted August 16, 2010 Posted August 16, 2010 I must have been bored... Try this - no error control (defun c:test (/ ed v-lst fn pt str) (vl-load-com) (setq ed (entget (car (entsel "\nSelect polyline"))) v-lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) ed));list of vertices fn (open "c:\\test.txt" "w") str "") (if (assoc 38 ed) (setq z (rtos (cdr (assoc 38 ed)) 2 4));4 = precision (setq z (rtos 0.0 2 4)) ) (foreach pt v-lst (setq x (rtos (car pt) 2 4) y (rtos (cadr pt) 2 4) ) (setq str (strcat x "," y "," z)) (write-line str fn) (setq str "") ) (close fn) (princ) ) Quote
Lee Mac Posted August 16, 2010 Posted August 16, 2010 Take a look at the Point Manager Program in my Signature, it should be able to do what you want, and a lot more. Lee Quote
Ramana Posted August 17, 2010 Author Posted August 17, 2010 Dear friends, thanks a lot, i have got an idea with the code which you have given. Now i will work for the rest to take the text also along with coordinates to txt file. thanks a lot once again. Ramana Quote
Ramana Posted August 19, 2010 Author Posted August 19, 2010 Dear friends, Greetings I have followed and used to export the coordinates of the pline and i have added few more lines of functions for my requirement. Actually my requirement is i need to export the coordinates of rectange and two more text information by selecting all at a time. for my ease i am selecting the plines first and then all text. I am able to export to txt file but the first text is only repeating. i am unable to get to mistake what am doing in this program. I am attaching drawing and lisp routine also Please help me where i am going wrong. (defun c:test (/ ed v-lst fn pt str) (vl-load-com) (setq pl(ssget '( ( 0 . "LWPOLYLINE"))) mtxt(ssget '((0 . "MTEXT"))) PLNO(SSLENGTH PL) mtno (sslength mtxt) POS 0 MTPOS 0 PTLIST1(LIST "") fn (open "c:\\test.csv" "w") OUTPUT "" ) (REPEAT PLNO (SETQ BOOTH(SSNAME PL POS)) (setq ed (entget BOOTH) v-lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) ed));list of vertices str "" str1 "") (foreach pt v-lst (setq x (rtos (car pt) 2 4) y (rtos (cadr pt) 2 4) str (strcat x "," y ) str1 (strcat str1 "," str) ) ;(setq str (strcat x "," y )) ;CALCULATING CO-ORINDATES FOR TESTING TEXT (setq x (car pt) y (cadr pt) ) (setq ptlist(list x y ) ptlist1(append ptlist1 ptlist)) ); FOR EACH (while (/= count 2) (SETQ MTEXT(SSNAME MTXT MTPOS) MTEXTinfo(entget MTEXT) MTXY(CDR (ASSOC 10 MTEXTINFO)) MTX(CAR MTXY) MTY(CADR MTXY) ) (IF (AND (< MTX (NTH 3 PTLIST1) ) (< MTY (NTH 4 PTLIST1) )(> MTX (NTH 7 PTLIST1) ) (> MTY (NTH 8 PTLIST1) )) (PROGN (SETQ MTCONT(cdr (assoc 1 MTEXTINFO)) COUNT(1+ COUNT) MTPOS(1+ MTPOS) ) (setq output(strcat output "," mtcont)) ) (PROGN (SETQ MTPOS(1+ MTPOS))) );IF ); while (alert output) (write-line (strcat output str1) fn) (SETQ pos(1+ pos) count 0 mtpos 0 output "" ) );PL REPEAT (close fn) ) Ramana ext_text_layers(2).dwg Quote
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.