flausbert Posted March 31, 2012 Posted March 31, 2012 Hi all! I have been getting benefit out of your great knowledge of autocad lisps on this forum for such a long time but first time i could not find what i look for so i am posting this. I appreciate if you could help me out. Thanks to you guys i am using lisp posted here http://www.cadtutor.net/forum/showthread.php?31653-Lisp-coordinates-of-points-to-excel-sheet-(-point-number) Other than this great lisp, i was wondering if you could arrange something for putting label to those points instead only number. It perfectly generates numbers but what i really want put a label i can define with consecutive numbers following like WO 1, WO 2, WO 3... i would be more than happy if you could give a hand Quote
Lee Mac Posted March 31, 2012 Posted March 31, 2012 Here is a quick generic point labelling program: (defun c:ptlabel ( / ht i l pr s sf ts ) (setq pr (getstring t "\nSpecify Label Prefix <None>: ") sf (getstring t "\nSpecify Label Suffix <None>: ") st (cond ((getint (strcat "\nSpecify Start Number <" (itoa (setq st (cond (st) (1)))) ">: "))) (st)) ht (cons 40 (getvar 'TEXTSIZE)) ts (cons 7 (getvar 'TEXTSTYLE)) ) (initget "LtR RtL BtT TtB") (setq dr (cond ((getkword (strcat "\nSpecify Direction [LtR/RtL/BtT/TtB] <" (setq dr (cond (dr) ("LtR"))) ">: "))) (dr))) (if (setq s (ssget '((0 . "POINT")))) (progn (repeat (setq i (sslength s)) (setq l (cons (assoc 10 (entget (ssname s (setq i (1- i))))) l)) ) (foreach pt (vl-sort l (cdr (assoc dr '( ("LtR" . (lambda ( a b ) (< (cadr a) (cadr b)))) ("RtL" . (lambda ( a b ) (> (cadr a) (cadr b)))) ("BtT" . (lambda ( a b ) (< (caddr a) (caddr b)))) ("TtB" . (lambda ( a b ) (> (caddr a) (caddr b)))) ) ) ) ) (entmake (list '(0 . "TEXT") pt ht ts '(72 . 1) '(73 . 2) (cons 11 (cdr pt)) (cons 1 (strcat pr (itoa st) sf)))) (setq st (1+ st)) ) ) ) (princ) ) Quote
flausbert Posted March 31, 2012 Author Posted March 31, 2012 Gives bad argument. Would you check again pls Quote
marko_ribar Posted March 31, 2012 Posted March 31, 2012 Here, I've corrected... Maybe Lee was in rush hour... (defun c:ptlabel ( / dr ht i lst pr s st sf ts ) (setq pr (getstring t "\nSpecify Label Prefix <None>: ") sf (getstring t "\nSpecify Label Suffix <None>: ") st (cond ((getint (strcat "\nSpecify Start Number <" (itoa (setq st (cond (st) (1)))) ">: "))) (st)) ht (cons 40 (getvar 'TEXTSIZE)) ts (cons 7 (getvar 'TEXTSTYLE)) ) (initget "LtR RtL BtT TtB") (setq dr (cond ((getkword (strcat "\nSpecify Direction [LtR/RtL/BtT/TtB] <" (setq dr (cond (dr) ("LtR"))) ">: "))) (dr))) (if (setq s (ssget '((0 . "POINT")))) (progn (repeat (setq i (sslength s)) (setq lst (cons (cdr (assoc 10 (entget (ssname s (setq i (1- i)))))) lst)) ) (foreach pt (vl-sort lst (cdr (assoc dr '( ("LtR" . (lambda ( a b ) (< (car a) (car b)))) ("RtL" . (lambda ( a b ) (> (car a) (car b)))) ("BtT" . (lambda ( a b ) (< (cadr a) (cadr b)))) ("TtB" . (lambda ( a b ) (> (cadr a) (cadr b)))) ) ) ) ) (entmake (list '(0 . "TEXT") (cons 10 pt) ht ts '(72 . 1) '(73 . 2) (cons 11 pt) (cons 1 (strcat pr (itoa st) sf)))) (setq st (1+ st)) ) ) ) (princ) ) Lee, hope you want be angry... Cheers and happy weekend... M.R. Quote
Lee Mac Posted March 31, 2012 Posted March 31, 2012 Gives bad argument. Would you check again pls All works for me, I see no error with my code Quote
flausbert Posted March 31, 2012 Author Posted March 31, 2012 Lee and Marko, thank you both. Works perfectly fine now. Since i catch you both here, you think it is possible to revise it in a way that labels can come from one column of excel as the points come from other column ? And i need to be able to export coordinates with these labels into excel as in here: http://www.cadtutor.net/forum/showthread.php?31653-Lisp-coordinates-of-points-to-excel-sheet-(-point-number Quote
flausbert Posted March 31, 2012 Author Posted March 31, 2012 i cant believe the post i have been mentioning since morning has got it all. i Just didnt read till end. Many thanks to VVA and Lee i also see your contributions in that post. You guys are incredible Quote
marko_ribar Posted March 31, 2012 Posted March 31, 2012 Try this : (defun c:ptlabel ( / dr fn file ht i lst pr s st sf ts ) (setq pr (getstring t "\nSpecify Label Prefix <None>: ") sf (getstring t "\nSpecify Label Suffix <None>: ") st (cond ((getint (strcat "\nSpecify Start Number <" (itoa (setq st (cond (st) (1)))) ">: "))) (st)) ht (cons 40 (getvar 'TEXTSIZE)) ts (cons 7 (getvar 'TEXTSTYLE)) ) (initget "LtR RtL BtT TtB") (setq dr (cond ((getkword (strcat "\nSpecify Direction [LtR/RtL/BtT/TtB] <" (setq dr (cond (dr) ("LtR"))) ">: "))) (dr))) (if (setq s (ssget '((0 . "POINT")))) (progn (setq fn (getfiled "Enter file to save to" (getvar 'dwgprefix) "csv" 1)) (setq file (open fn "w")) (repeat (setq i (sslength s)) (setq lst (cons (cdr (assoc 10 (entget (ssname s (setq i (1- i)))))) lst)) ) (foreach pt (vl-sort lst (cdr (assoc dr '( ("LtR" . (lambda ( a b ) (< (car a) (car b)))) ("RtL" . (lambda ( a b ) (> (car a) (car b)))) ("BtT" . (lambda ( a b ) (< (cadr a) (cadr b)))) ("TtB" . (lambda ( a b ) (> (cadr a) (cadr b)))) ) ) ) ) (entmake (list '(0 . "TEXT") (cons 10 pt) ht ts '(72 . 1) '(73 . 2) (cons 11 pt) (cons 1 (strcat pr (itoa st) sf)))) (write-line (strcat pr (itoa st) sf "," (vl-princ-to-string pt)) file) (setq st (1+ st)) ) (close file) (startapp "explorer.exe" fn) ) ) (princ) ) If I understood correctly, you wanted to export POINT data from CAD to EXCEL... Option is through CSV file; after you start EXCEL you can afterwards save sheet data to any EXCEL file format like XLS and so on... Cheers, M.R. Quote
flausbert Posted March 31, 2012 Author Posted March 31, 2012 i actually was thinking if we have 2 columns in excel sheet, such as 213123.21,123141,54 and another adjacent column as description of this point like POINT 1. Could we take this description and put right on the point given with coordinates ? 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.